comparison raw.c @ 4611:96d4d0710099 libavcodec

quicktime 'raw ' support
author bcoudurier
date Thu, 01 Mar 2007 13:03:33 +0000
parents ce643a22f049
children 9358bf66a1d0
comparison
equal deleted inserted replaced
4610:c81aa982b72b 4611:96d4d0710099
61 { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') }, 61 { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
62 62
63 { -1, 0 }, 63 { -1, 0 },
64 }; 64 };
65 65
66 static int findPixelFormat(unsigned int fourcc) 66 static const PixelFormatTag pixelFormatBpsAVI[] = {
67 { 67 { PIX_FMT_PAL8, 8 },
68 const PixelFormatTag * tags = pixelFormatTags; 68 { PIX_FMT_RGB555, 15 },
69 { PIX_FMT_RGB555, 16 },
70 { PIX_FMT_BGR24, 24 },
71 { PIX_FMT_RGB32, 32 },
72 { -1, 0 },
73 };
74
75 static const PixelFormatTag pixelFormatBpsMOV[] = {
76 /* FIXME fix swscaler to support those */
77 /* http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html */
78 { PIX_FMT_PAL8, 8 },
79 { PIX_FMT_BGR555, 16 },
80 { PIX_FMT_RGB24, 24 },
81 { PIX_FMT_BGR32_1, 32 },
82 { -1, 0 },
83 };
84
85 static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
86 {
69 while (tags->pix_fmt >= 0) { 87 while (tags->pix_fmt >= 0) {
70 if (tags->fourcc == fourcc) 88 if (tags->fourcc == fourcc)
71 return tags->pix_fmt; 89 return tags->pix_fmt;
72 tags++; 90 tags++;
73 } 91 }
89 107
90 static int raw_init_decoder(AVCodecContext *avctx) 108 static int raw_init_decoder(AVCodecContext *avctx)
91 { 109 {
92 RawVideoContext *context = avctx->priv_data; 110 RawVideoContext *context = avctx->priv_data;
93 111
94 if (avctx->codec_tag) 112 if (avctx->codec_tag == MKTAG('r','a','w',' '))
95 avctx->pix_fmt = findPixelFormat(avctx->codec_tag); 113 avctx->pix_fmt = findPixelFormat(pixelFormatBpsMOV, avctx->bits_per_sample);
96 else if (avctx->bits_per_sample){ 114 else if (avctx->codec_tag)
97 switch(avctx->bits_per_sample){ 115 avctx->pix_fmt = findPixelFormat(pixelFormatTags, avctx->codec_tag);
98 case 8: avctx->pix_fmt= PIX_FMT_PAL8 ; break; 116 else if (avctx->bits_per_sample)
99 case 15: avctx->pix_fmt= PIX_FMT_RGB555; break; 117 avctx->pix_fmt = findPixelFormat(pixelFormatBpsAVI, avctx->bits_per_sample);
100 case 16: avctx->pix_fmt= PIX_FMT_RGB555; break;
101 case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break;
102 case 32: avctx->pix_fmt= PIX_FMT_RGB32; break;
103 }
104 }
105 118
106 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); 119 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
107 context->buffer = av_malloc(context->length); 120 context->buffer = av_malloc(context->length);
108 context->pic.pict_type = FF_I_TYPE; 121 context->pic.pict_type = FF_I_TYPE;
109 context->pic.key_frame = 1; 122 context->pic.key_frame = 1;