[Ffmpeg-cvslog] CVS: ffmpeg ffmpeg.c,1.378,1.379

Luca Abeni CVS lucabe
Thu Apr 20 14:57:22 CEST 2006


Update of /cvsroot/ffmpeg/ffmpeg
In directory mail:/var2/tmp/cvs-serv3215

Modified Files:
	ffmpeg.c 
Log Message:
Simplify the code used for assigning video_resample, video_crop, & video_pad


Index: ffmpeg.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/ffmpeg.c,v
retrieving revision 1.378
retrieving revision 1.379
diff -u -d -r1.378 -r1.379
--- ffmpeg.c	10 Apr 2006 10:16:13 -0000	1.378
+++ ffmpeg.c	20 Apr 2006 12:57:19 -0000	1.379
@@ -1632,49 +1632,31 @@
                 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 @@
                             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;





More information about the ffmpeg-cvslog mailing list