- &unescaped_buf_ptr, &unescaped_buf_size);
- {
- /* EOF */
- if (start_code < 0) {
- goto the_end;
- } else {
- av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n", start_code, buf_end - buf_ptr);
-
- init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size*8);
-
- s->start_code = start_code;
- if(s->avctx->debug & FF_DEBUG_STARTCODE){
- av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
- }
-
- /* process markers */
- if (start_code >= 0xd0 && start_code <= 0xd7) {
- av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", start_code&0x0f);
- /* APP fields */
- } else if (start_code >= APP0 && start_code <= APP15) {
- mjpeg_decode_app(s);
- /* Comment */
- } else if (start_code == COM){
- mjpeg_decode_com(s);
+ &unescaped_buf_ptr,
+ &unescaped_buf_size);
+ /* EOF */
+ if (start_code < 0) {
+ goto the_end;
+ } else {
+ av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
+ start_code, buf_end - buf_ptr);
+
+ init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size * 8);
+
+ s->start_code = start_code;
+ if (s->avctx->debug & FF_DEBUG_STARTCODE)
+ av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
+
+ /* process markers */
+ if (start_code >= 0xd0 && start_code <= 0xd7)
+ av_log(avctx, AV_LOG_DEBUG,
+ "restart marker: %d\n", start_code & 0x0f);
+ /* APP fields */
+ else if (start_code >= APP0 && start_code <= APP15)
+ mjpeg_decode_app(s);
+ /* Comment */
+ else if (start_code == COM)
+ mjpeg_decode_com(s);
+
+ switch (start_code) {
+ case SOI:
+ s->restart_interval = 0;
+ s->restart_count = 0;
+ /* nothing to do on SOI */
+ break;
+ case DQT:
+ ff_mjpeg_decode_dqt(s);
+ break;
+ case DHT:
+ if (ff_mjpeg_decode_dht(s) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n");
+ return -1;