comparison mjpeg.c @ 4615:f4a14f5afd8a libavcodec

support for mjpeg bottom field first in mov
author bcoudurier
date Fri, 02 Mar 2007 12:26:07 +0000
parents fc155ff94878
children 4effe3bde31b
comparison
equal deleted inserted replaced
4614:3c6c557aa977 4615:f4a14f5afd8a
963 av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n"); 963 av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
964 init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8); 964 init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
965 mjpeg_decode_dht(s); 965 mjpeg_decode_dht(s);
966 /* should check for error - but dunno */ 966 /* should check for error - but dunno */
967 } 967 }
968 if (avctx->extradata_size > 9 &&
969 AV_RL32(avctx->extradata + 4) == MKTAG('f','i','e','l')) {
970 if (avctx->extradata[9] == 6) { /* quicktime icefloe 019 */
971 s->interlace_polarity = 1; /* bottom field first */
972 av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
973 }
974 }
968 975
969 return 0; 976 return 0;
970 } 977 }
971 978
972 979
1183 /* test interlaced mode */ 1190 /* test interlaced mode */
1184 if (s->first_picture && 1191 if (s->first_picture &&
1185 s->org_height != 0 && 1192 s->org_height != 0 &&
1186 s->height < ((s->org_height * 3) / 4)) { 1193 s->height < ((s->org_height * 3) / 4)) {
1187 s->interlaced = 1; 1194 s->interlaced = 1;
1188 // s->bottom_field = (s->interlace_polarity) ? 1 : 0; 1195 s->bottom_field = s->interlace_polarity;
1189 s->bottom_field = 0; 1196 s->picture.interlaced_frame = 1;
1197 s->picture.top_field_first = !s->interlace_polarity;
1190 height *= 2; 1198 height *= 2;
1191 } 1199 }
1192 1200
1193 avcodec_set_dimensions(s->avctx, width, height); 1201 avcodec_set_dimensions(s->avctx, width, height);
1194 1202
1195 s->qscale_table= av_mallocz((s->width+15)/16); 1203 s->qscale_table= av_mallocz((s->width+15)/16);
1196 1204
1197 s->first_picture = 0; 1205 s->first_picture = 0;
1198 } 1206 }
1199 1207
1200 if(s->interlaced && s->bottom_field) 1208 if(s->interlaced && (s->bottom_field == !s->interlace_polarity))
1201 return 0; 1209 return 0;
1202 1210
1203 /* XXX: not complete test ! */ 1211 /* XXX: not complete test ! */
1204 pix_fmt_id = (s->h_count[0] << 20) | (s->v_count[0] << 16) | 1212 pix_fmt_id = (s->h_count[0] << 20) | (s->v_count[0] << 16) |
1205 (s->h_count[1] << 12) | (s->v_count[1] << 8) | 1213 (s->h_count[1] << 12) | (s->v_count[1] << 8) |
2165 eoi_parser: 2173 eoi_parser:
2166 { 2174 {
2167 if (s->interlaced) { 2175 if (s->interlaced) {
2168 s->bottom_field ^= 1; 2176 s->bottom_field ^= 1;
2169 /* if not bottom field, do not output image yet */ 2177 /* if not bottom field, do not output image yet */
2170 if (s->bottom_field) 2178 if (s->bottom_field == !s->interlace_polarity)
2171 goto not_the_end; 2179 goto not_the_end;
2172 } 2180 }
2173 *picture = s->picture; 2181 *picture = s->picture;
2174 *data_size = sizeof(AVFrame); 2182 *data_size = sizeof(AVFrame);
2175 2183