[FFmpeg-devel] [PATCH] MOV YUV2 fourcc -> PIX_FMT_YUYV422 mapping

Jai Menon jmenon86
Tue Mar 31 06:40:28 CEST 2009


On Mon, Mar 30, 2009 at 11:01 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Mar 30, 2009 at 11:12:10AM +0530, Jai Menon wrote:
>> On 3/26/09, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:
>> > On Thu, Mar 26, 2009 at 02:22:03PM +0530, Jai Menon wrote:
>> > ?> On 3/26/09, Michael Niedermayer <michaelni at gmx.at> wrote:
>> > ?> > On Wed, Mar 25, 2009 at 08:47:33AM -0700, Baptiste Coudurier wrote:
>> > ?> > ?> On 3/25/2009 8:35 AM, Reimar D?ffinger wrote:
>> > ?> > ?> > On Wed, Mar 25, 2009 at 03:01:50PM +0100, Michael Niedermayer wrote:
>> > ?> > ?> >> On Wed, Mar 25, 2009 at 09:48:51AM +0530, Jai Menon wrote:
>> > ?> > ?> >>> Index: libavcodec/rawdec.c
>> > ?> > ?> >>> ===================================================================
>> > ?> > ?> >>> --- libavcodec/rawdec.c ? (revision 17944)
>> > ?> > ?> >>> +++ libavcodec/rawdec.c ? (working copy)
>> > ?> > ?> >>> @@ -144,6 +144,13 @@
>> > ?> > ?> >>> ? ? ? ? ?picture->data[2] = tmp;
>> > ?> > ?> >>> ? ? ?}
>> > ?> > ?> >>>
>> > ?> > ?> >>> + ? ?if(avctx->codec_tag == MKTAG('y', 'u', 'v', '2')) {
>> > ?> > ?> >>> + ? ? ? ?int i;
>> > ?> > ?> >>> + ? ? ? ?for(i=1; i<picture->linesize[0]*avctx->height; i+=2) {
>> > ?> > ?> >>> + ? ? ? ? ? ?picture->data[0][i] ^= 128;
>> > ?> > ?> >>> + ? ? ? ?}
>> > ?> > ?> >>> + ? ?}
>> >
>> >
>> > I think you should avoid writing to the padding pixels, particularly
>> > ?since this would not work for negative linesize i.e. something
>> > ?like
>> > ?uint8_t *line = picture->data[0];
>> > ?for (y = 0; y < avctx->height; y++) {
>> > ? ? for (x = 0; x < avctx->width; x++)
>> > ? ? ? ? line[2*x + 1] ^= 0x80; // convert signed to unsigned
>> > ? ? line += picture->linesize[0];
>> >
>> > }
>> >
>>
>> Changed. I didn't realize linesize could be negative.
>>
>> > ?> Are you suggesting adding a similar if case in raw_encode which sets
>> > ?> the sign bit? such a patch will be quite intrusive, especially for a
>> > ?> pixel fmt which most people won't use :)
>> >
>> >
>> > Huh? Wouldn't you just need to add exactly the same code between
>> > ?avpicture_layout and the return?
>>
>> Nevermind, I was looking at adding it in imgconvert code :)
>> Revised patch attached.
>>
>> --
>> Regards,
>>
>> Jai
>
>> Index: libavcodec/rawenc.c
>> ===================================================================
>> --- libavcodec/rawenc.c ? ? ? (revision 17944)
>> +++ libavcodec/rawenc.c ? ? ? (working copy)
>> @@ -40,8 +40,19 @@
>> ?static int raw_encode(AVCodecContext *avctx,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char *frame, int buf_size, void *data)
>> ?{
>> - ? ?return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
>> + ? ?int ret = avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? avctx->height, frame, buf_size);
>> +
>> + ? ?if(avctx->codec_tag == MKTAG('y', 'u', 'v', '2') && (ret > 0)) {
>
> doesnt this need a pix_fmt check too?

if someone does force vtag, yeah :) didn't think of that.
check added.

>> + ? ? ? ?int i, j;
>> + ? ? ? ?uint8_t *line = frame;
>> + ? ? ? ?for(j = 0; j < avctx->height; j++) {
>> + ? ? ? ? ? ?for(i = 0; i < avctx->width; i++)
>
> x and y are better variable names in this case

Ok, changed.

[...]

revised patch attached.
-- 
Regards,

Jai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yuv2_mov_fourcc.patch
Type: text/x-patch
Size: 2769 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090331/ee470e56/attachment.bin>



More information about the ffmpeg-devel mailing list