diff options
author | Luca Abeni <lucabe72@email.it> | 2006-04-20 12:57:19 +0000 |
---|---|---|
committer | Luca Abeni <lucabe72@email.it> | 2006-04-20 12:57:19 +0000 |
commit | c3f11d199c2aa0590fb1b76ad994c1369dd02cde (patch) | |
tree | 1a148aa0d97db8af30c8ebff2560603818c5b085 /ffmpeg.c | |
parent | 50a6c318b2d00a103297f2aa6256a7404b0f64f8 (diff) | |
download | ffmpeg-c3f11d199c2aa0590fb1b76ad994c1369dd02cde.tar.gz |
Simplify the code used for assigning video_resample, video_crop, & video_pad
Originally committed as revision 5306 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 62 |
1 files changed, 19 insertions, 43 deletions
@@ -1632,49 +1632,31 @@ static int av_encode(AVFormatContext **output_files, ost->encoding_needed = 1; break; case CODEC_TYPE_VIDEO: - if (codec->width == icodec->width && - codec->height == icodec->height && - frame_topBand == 0 && - frame_bottomBand == 0 && - frame_leftBand == 0 && - frame_rightBand == 0 && - frame_padtop == 0 && - frame_padbottom == 0 && - frame_padleft == 0 && - frame_padright == 0) - { - ost->video_resample = 0; - ost->video_crop = 0; - ost->video_pad = 0; - } else if ((codec->width == icodec->width - - (frame_leftBand + frame_rightBand)) && - (codec->height == icodec->height - - (frame_topBand + frame_bottomBand)) && - (frame_rightBand + frame_leftBand + frame_topBand + frame_bottomBand)) { - ost->video_resample = 0; - ost->video_crop = 1; + ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0); + ost->video_pad = ((frame_padleft + frame_padright + frame_padtop + frame_padbottom) != 0); + ost->video_resample = ((codec->width != icodec->width - + (frame_leftBand + frame_rightBand) + + (frame_padleft + frame_padright)) || + (codec->height != icodec->height - + (frame_topBand + frame_bottomBand) + + (frame_padtop + frame_padbottom))); + if (ost->video_crop) { ost->topBand = frame_topBand; ost->leftBand = frame_leftBand; - } else if ((codec->width == icodec->width + - (frame_padleft + frame_padright)) && - (codec->height == icodec->height + - (frame_padtop + frame_padbottom)) && - (frame_padright + frame_padleft + frame_padtop + frame_padbottom)) { - ost->video_resample = 0; - ost->video_crop = 0; - ost->video_pad = 1; + } + if (ost->video_pad) { ost->padtop = frame_padtop; ost->padleft = frame_padleft; ost->padbottom = frame_padbottom; ost->padright = frame_padright; - avcodec_get_frame_defaults(&ost->pict_tmp); - if( avpicture_alloc( (AVPicture*)&ost->pict_tmp, codec->pix_fmt, - codec->width, codec->height ) ) - goto fail; - } else { - ost->video_resample = 1; - ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0); - ost->video_pad = ((frame_padleft + frame_padright + frame_padtop + frame_padbottom) != 0); + if (!ost->video_resample) { + avcodec_get_frame_defaults(&ost->pict_tmp); + if( avpicture_alloc( (AVPicture*)&ost->pict_tmp, codec->pix_fmt, + codec->width, codec->height ) ) + goto fail; + } + } + if (ost->video_resample) { avcodec_get_frame_defaults(&ost->pict_tmp); if( avpicture_alloc( (AVPicture*)&ost->pict_tmp, PIX_FMT_YUV420P, codec->width, codec->height ) ) @@ -1686,12 +1668,6 @@ static int av_encode(AVFormatContext **output_files, icodec->width - (frame_leftBand + frame_rightBand), icodec->height - (frame_topBand + frame_bottomBand)); - ost->padtop = frame_padtop; - ost->padleft = frame_padleft; - ost->padbottom = frame_padbottom; - ost->padright = frame_padright; - ost->topBand = frame_topBand; - ost->leftBand = frame_leftBand; } ost->encoding_needed = 1; ist->decoding_needed = 1; |