| OLD | NEW |
| 1 /* | 1 /* |
| 2 * MJPEG decoder | 2 * MJPEG decoder |
| 3 * Copyright (c) 2000, 2001 Fabrice Bellard | 3 * Copyright (c) 2000, 2001 Fabrice Bellard |
| 4 * Copyright (c) 2003 Alex Beregszaszi | 4 * Copyright (c) 2003 Alex Beregszaszi |
| 5 * Copyright (c) 2003-2004 Michael Niedermayer | 5 * Copyright (c) 2003-2004 Michael Niedermayer |
| 6 * | 6 * |
| 7 * Support for external huffman table, various fixes (AVID workaround), | 7 * Support for external huffman table, various fixes (AVID workaround), |
| 8 * aspecting, new decode_frame mechanism and apple mjpeg-b support | 8 * aspecting, new decode_frame mechanism and apple mjpeg-b support |
| 9 * by Alex Beregszaszi | 9 * by Alex Beregszaszi |
| 10 * | 10 * |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 height = get_bits(&s->gb, 16); | 214 height = get_bits(&s->gb, 16); |
| 215 width = get_bits(&s->gb, 16); | 215 width = get_bits(&s->gb, 16); |
| 216 | 216 |
| 217 //HACK for odd_height.mov | 217 //HACK for odd_height.mov |
| 218 if(s->interlaced && s->width == width && s->height == height + 1) | 218 if(s->interlaced && s->width == width && s->height == height + 1) |
| 219 height= s->height; | 219 height= s->height; |
| 220 | 220 |
| 221 av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); | 221 av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); |
| 222 if(av_check_image_size(width, height, 0, s->avctx)) | 222 if(av_image_check_size(width, height, 0, s->avctx)) |
| 223 return -1; | 223 return -1; |
| 224 | 224 |
| 225 nb_components = get_bits(&s->gb, 8); | 225 nb_components = get_bits(&s->gb, 8); |
| 226 if (nb_components <= 0 || | 226 if (nb_components <= 0 || |
| 227 nb_components > MAX_COMPONENTS) | 227 nb_components > MAX_COMPONENTS) |
| 228 return -1; | 228 return -1; |
| 229 if (s->ls && !(s->bits <= 8 || nb_components == 1)){ | 229 if (s->ls && !(s->bits <= 8 || nb_components == 1)){ |
| 230 av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray
accepted for JPEG-LS\n"); | 230 av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray
accepted for JPEG-LS\n"); |
| 231 return -1; | 231 return -1; |
| 232 } | 232 } |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 static int mjpeg_decode_app(MJpegDecodeContext *s) | 1020 static int mjpeg_decode_app(MJpegDecodeContext *s) |
| 1021 { | 1021 { |
| 1022 int len, id, i; | 1022 int len, id, i; |
| 1023 | 1023 |
| 1024 len = get_bits(&s->gb, 16); | 1024 len = get_bits(&s->gb, 16); |
| 1025 if (len < 5) | 1025 if (len < 5) |
| 1026 return -1; | 1026 return -1; |
| 1027 if(8*len + get_bits_count(&s->gb) > s->gb.size_in_bits) | 1027 if(8*len + get_bits_count(&s->gb) > s->gb.size_in_bits) |
| 1028 return -1; | 1028 return -1; |
| 1029 | 1029 |
| 1030 id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16); | 1030 id = get_bits_long(&s->gb, 32); |
| 1031 id = av_be2ne32(id); | 1031 id = av_be2ne32(id); |
| 1032 len -= 6; | 1032 len -= 6; |
| 1033 | 1033 |
| 1034 if(s->avctx->debug & FF_DEBUG_STARTCODE){ | 1034 if(s->avctx->debug & FF_DEBUG_STARTCODE){ |
| 1035 av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id); | 1035 av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 /* buggy AVID, it puts EOI only at every 10th frame */ | 1038 /* buggy AVID, it puts EOI only at every 10th frame */ |
| 1039 /* also this fourcc is used by non-avid files too, it holds some | 1039 /* also this fourcc is used by non-avid files too, it holds some |
| 1040 informations, but it's always present in AVID creates files */ | 1040 informations, but it's always present in AVID creates files */ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 default: | 1127 default: |
| 1128 av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace\n"); | 1128 av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace\n"); |
| 1129 } | 1129 } |
| 1130 len -= 9; | 1130 len -= 9; |
| 1131 goto out; | 1131 goto out; |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 /* Apple MJPEG-A */ | 1134 /* Apple MJPEG-A */ |
| 1135 if ((s->start_code == APP1) && (len > (0x28 - 8))) | 1135 if ((s->start_code == APP1) && (len > (0x28 - 8))) |
| 1136 { | 1136 { |
| 1137 id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16); | 1137 id = get_bits_long(&s->gb, 32); |
| 1138 id = av_be2ne32(id); | 1138 id = av_be2ne32(id); |
| 1139 len -= 4; | 1139 len -= 4; |
| 1140 if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */ | 1140 if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */ |
| 1141 { | 1141 { |
| 1142 #if 0 | 1142 #if 0 |
| 1143 skip_bits(&s->gb, 32); /* field size */ | 1143 skip_bits(&s->gb, 32); /* field size */ |
| 1144 skip_bits(&s->gb, 32); /* pad field size */ | 1144 skip_bits(&s->gb, 32); /* pad field size */ |
| 1145 skip_bits(&s->gb, 32); /* next off */ | 1145 skip_bits(&s->gb, 32); /* next off */ |
| 1146 skip_bits(&s->gb, 32); /* quant off */ | 1146 skip_bits(&s->gb, 32); /* quant off */ |
| 1147 skip_bits(&s->gb, 32); /* huff off */ | 1147 skip_bits(&s->gb, 32); /* huff off */ |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 sizeof(MJpegDecodeContext), | 1554 sizeof(MJpegDecodeContext), |
| 1555 ff_mjpeg_decode_init, | 1555 ff_mjpeg_decode_init, |
| 1556 NULL, | 1556 NULL, |
| 1557 ff_mjpeg_decode_end, | 1557 ff_mjpeg_decode_end, |
| 1558 ff_mjpeg_decode_frame, | 1558 ff_mjpeg_decode_frame, |
| 1559 CODEC_CAP_DR1, | 1559 CODEC_CAP_DR1, |
| 1560 NULL, | 1560 NULL, |
| 1561 .max_lowres = 3, | 1561 .max_lowres = 3, |
| 1562 .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"), | 1562 .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"), |
| 1563 }; | 1563 }; |
| OLD | NEW |