[FFmpeg-devel] [PATCH] simplify crop/pad handling in ffmpeg.c

Hervé herve.flores
Wed Apr 16 14:58:15 CEST 2008


Le 16 avr. 08 ? 14:13, Luca Abeni a ?crit :
> Hi,
>
> Herv? wrote:
> [...]
>>> Sorry; maybe I am missing something, but I see this check removed
>>> from here
>>> and not re-introduced in other places... Do we support cropping and
>>> padding
>>> with non-multiple-of-2 quantities?
>>
>> the idea of this patch (not from me but from a guy from pixar, sent  
>> in
>> the list a long time ago) was to permit an odd value for pad and  
>> crop.
>
> So, padding and/or cropping with odd values is supported? If yes, then
> the patch looks ok... But the patch description is not ok: the patch  
> is
> not simplifying the code, but removing wrong checks (assuming that
> odd pad/crop values are ok).

yes

> [...]
>> PS: I don't remember exactly what was the pb and how to reproduce it,
>> but if I well remeber, this patch have a pb with chroma and  
>> interlaced
>> streams (bad resample, no "swap"/reinterlacing of the chroma channel)
>> eg: file has an even height, if you -padbottom 1 and -padtop 1 => no
>> good chroma resample
>>
>> another bug with this patch:  file has an even height, if you -
>> cropbottom 1 and -padbottom 1 => no change (no pad, no crop)
>
> This seems to indicate that padding/cropping with odd values is not
> well supported... :)

if I well remember (I didn't try it since.. some time), double odd  
values for pad or crop give some side effects with interlaced contents
a single odd value for pad or crop is OK

eg: just add these lines before the end of the patch:

	if (((frame_padright % 2) != 0 && (frame_padleft % 2) != 0) ||  
((frame_padtop % 2) != 0 && (frame_padbottom % 2) != 0) {
             fprintf(stderr, "Error for size:  Do not play with video  
if you don't know what you are doing :)");
             exit(1);
	}

// and now then the end of the patch, the final check:


+        if ((video_enc->width % 2) != 0 || (video_enc->height % 2) !=  
0) {
+            fprintf(stderr, "Error for %s:  Resulting size [%dx%d]"
+                            "is not a multiple of 2.\n",
+                    oc->filename, video_enc->width, video_enc->height);
+            exit(1);
+        }


(PS: I made a GUI for Mac, I sent my diff to Diego, he sent it to the  
mailing list, these diff were not prepare for inclusion in svn, I just  
use them.)
bye

Herv?



More information about the ffmpeg-devel mailing list