| 
																	
																	
																		
																	
																	
																 | 
																@@ -250,7 +250,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																    int v_count[MAX_COMPONENTS] = { 0 }; | 
																 | 
																 | 
																    int v_count[MAX_COMPONENTS] = { 0 }; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    s->cur_scan = 0; | 
																 | 
																 | 
																    s->cur_scan = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																    s->upscale_h = s->upscale_v = 0; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    memset(s->upscale_h, 0, sizeof(s->upscale_h)); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    memset(s->upscale_v, 0, sizeof(s->upscale_v)); | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    /* XXX: verify len field validity */ | 
																 | 
																 | 
																    /* XXX: verify len field validity */ | 
															
														
														
													
														
															
																 | 
																 | 
																    len     = get_bits(&s->gb, 16); | 
																 | 
																 | 
																    len     = get_bits(&s->gb, 16); | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																		
																	
																	
																 | 
																@@ -404,8 +405,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																            js = (pix_fmt_id >> (16 + 4*(i&1))) & 0xF; | 
																 | 
																 | 
																            js = (pix_fmt_id >> (16 + 4*(i&1))) & 0xF; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																        if (is == 1 && js == 2) { | 
																 | 
																 | 
																        if (is == 1 && js == 2) { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (i & 1) s->upscale_h |= 1 << (j/2); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																            else       s->upscale_v |= 1 << (j/2); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            if (i & 1) s->upscale_h[j/2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            else       s->upscale_v[j/2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } | 
																 | 
																 | 
																        } | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																		
																	
																	
																 | 
																@@ -441,12 +442,12 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																    case 0x22111111: | 
																 | 
																 | 
																    case 0x22111111: | 
															
														
														
													
														
															
																 | 
																 | 
																        if (s->adobe_transform == 0 && s->bits <= 8) { | 
																 | 
																 | 
																        if (s->adobe_transform == 0 && s->bits <= 8) { | 
															
														
														
													
														
															
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_GBRAP; | 
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_GBRAP; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_v |= 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_h |= 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_v[1] = s->upscale_v[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_h[1] = s->upscale_h[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else if (s->adobe_transform == 2 && s->bits <= 8) { | 
																 | 
																 | 
																        } else if (s->adobe_transform == 2 && s->bits <= 8) { | 
															
														
														
													
														
															
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_YUVA444P; | 
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_YUVA444P; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_v |= 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_h |= 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_v[1] = s->upscale_v[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_h[1] = s->upscale_h[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; | 
																 | 
																 | 
																            s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else { | 
																 | 
																 | 
																        } else { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P; | 
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P; | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																		
																	
																	
																 | 
																@@ -495,10 +496,10 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; | 
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; | 
															
														
														
													
														
															
																 | 
																 | 
																            else | 
																 | 
																 | 
																            else | 
															
														
														
													
														
															
																 | 
																 | 
																                goto unk_pixfmt; | 
																 | 
																 | 
																                goto unk_pixfmt; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_v |= 3; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_v[0] = s->upscale_v[1] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else { | 
																 | 
																 | 
																        } else { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (pix_fmt_id == 0x14111100) | 
																 | 
																 | 
																            if (pix_fmt_id == 0x14111100) | 
															
														
														
													
														
															
																 | 
																 | 
																                s->upscale_v |= 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																                s->upscale_v[1] = s->upscale_v[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P; | 
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P; | 
															
														
														
													
														
															
																 | 
																 | 
																            else | 
																 | 
																 | 
																            else | 
															
														
														
													
														
															
																 | 
																 | 
																                goto unk_pixfmt; | 
																 | 
																 | 
																                goto unk_pixfmt; | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -510,7 +511,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; | 
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; | 
															
														
														
													
														
															
																 | 
																 | 
																            else | 
																 | 
																 | 
																            else | 
															
														
														
													
														
															
																 | 
																 | 
																                goto unk_pixfmt; | 
																 | 
																 | 
																                goto unk_pixfmt; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_h |= 3; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_h[0] = s->upscale_h[1] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else { | 
																 | 
																 | 
																        } else { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; | 
																 | 
																 | 
																            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; | 
															
														
														
													
														
															
																 | 
																 | 
																            else              s->avctx->pix_fmt = AV_PIX_FMT_YUV422P16; | 
																 | 
																 | 
																            else              s->avctx->pix_fmt = AV_PIX_FMT_YUV422P16; | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -533,11 +534,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																        if (pix_fmt_id == 0x42111100) { | 
																 | 
																 | 
																        if (pix_fmt_id == 0x42111100) { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits > 8) | 
																 | 
																 | 
																            if (s->bits > 8) | 
															
														
														
													
														
															
																 | 
																 | 
																                goto unk_pixfmt; | 
																 | 
																 | 
																                goto unk_pixfmt; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_h = 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_h[1] = s->upscale_h[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else if (pix_fmt_id == 0x24111100) { | 
																 | 
																 | 
																        } else if (pix_fmt_id == 0x24111100) { | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->bits > 8) | 
																 | 
																 | 
																            if (s->bits > 8) | 
															
														
														
													
														
															
																 | 
																 | 
																                goto unk_pixfmt; | 
																 | 
																 | 
																                goto unk_pixfmt; | 
															
														
														
													
														
															
																 | 
																 | 
																            s->upscale_v = 6; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            s->upscale_v[1] = s->upscale_v[2] = 1; | 
															
														
														
													
														
															
																 | 
																 | 
																        } | 
																 | 
																 | 
																        } | 
															
														
														
													
														
															
																 | 
																 | 
																        break; | 
																 | 
																 | 
																        break; | 
															
														
														
													
														
															
																 | 
																 | 
																    case 0x41111100: | 
																 | 
																 | 
																    case 0x41111100: | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -549,15 +550,17 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) | 
															
														
														
													
														
															
																 | 
																 | 
																    default: | 
																 | 
																 | 
																    default: | 
															
														
														
													
														
															
																 | 
																 | 
																unk_pixfmt: | 
																 | 
																 | 
																unk_pixfmt: | 
															
														
														
													
														
															
																 | 
																 | 
																        av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x bits:%d\n", pix_fmt_id, s->bits); | 
																 | 
																 | 
																        av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x bits:%d\n", pix_fmt_id, s->bits); | 
															
														
														
													
														
															
																 | 
																 | 
																        s->upscale_h = s->upscale_v = 0; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        memset(s->upscale_h, 0, sizeof(s->upscale_h)); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        memset(s->upscale_v, 0, sizeof(s->upscale_v)); | 
															
														
														
													
														
															
																 | 
																 | 
																        return AVERROR_PATCHWELCOME; | 
																 | 
																 | 
																        return AVERROR_PATCHWELCOME; | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																    if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if ((AV_RB32(s->upscale_h) || AV_RB32(s->upscale_v)) && s->avctx->lowres) { | 
															
														
														
													
														
															
																 | 
																 | 
																        av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n"); | 
																 | 
																 | 
																        av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n"); | 
															
														
														
													
														
															
																 | 
																 | 
																        return AVERROR_PATCHWELCOME; | 
																 | 
																 | 
																        return AVERROR_PATCHWELCOME; | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																    if (s->ls) { | 
																 | 
																 | 
																    if (s->ls) { | 
															
														
														
													
														
															
																 | 
																 | 
																        s->upscale_h = s->upscale_v = 0; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        memset(s->upscale_h, 0, sizeof(s->upscale_h)); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        memset(s->upscale_v, 0, sizeof(s->upscale_v)); | 
															
														
														
													
														
															
																 | 
																 | 
																        if (s->nb_components == 3) { | 
																 | 
																 | 
																        if (s->nb_components == 3) { | 
															
														
														
													
														
															
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_RGB24; | 
																 | 
																 | 
																            s->avctx->pix_fmt = AV_PIX_FMT_RGB24; | 
															
														
														
													
														
															
																 | 
																 | 
																        } else if (s->nb_components != 1) { | 
																 | 
																 | 
																        } else if (s->nb_components != 1) { | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																		
																	
																	
																 | 
																@@ -2129,7 +2132,7 @@ the_end: | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step_minus1; | 
																 | 
																 | 
																    is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step_minus1; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    if (s->upscale_h) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if (AV_RB32(s->upscale_h)) { | 
															
														
														
													
														
															
																 | 
																 | 
																        int p; | 
																 | 
																 | 
																        int p; | 
															
														
														
													
														
															
																 | 
																 | 
																        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || | 
																 | 
																 | 
																        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || | 
															
														
														
													
														
															
																 | 
																 | 
																                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  || | 
																 | 
																 | 
																                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  || | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -2149,13 +2152,13 @@ the_end: | 
															
														
														
													
														
															
																 | 
																 | 
																            uint8_t *line = s->picture_ptr->data[p]; | 
																 | 
																 | 
																            uint8_t *line = s->picture_ptr->data[p]; | 
															
														
														
													
														
															
																 | 
																 | 
																            int w = s->width; | 
																 | 
																 | 
																            int w = s->width; | 
															
														
														
													
														
															
																 | 
																 | 
																            int h = s->height; | 
																 | 
																 | 
																            int h = s->height; | 
															
														
														
													
														
															
																 | 
																 | 
																            if (!(s->upscale_h & (1<<p))) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            if (!s->upscale_h[p]) | 
															
														
														
													
														
															
																 | 
																 | 
																                continue; | 
																 | 
																 | 
																                continue; | 
															
														
														
													
														
															
																 | 
																 | 
																            if (p==1 || p==2) { | 
																 | 
																 | 
																            if (p==1 || p==2) { | 
															
														
														
													
														
															
																 | 
																 | 
																                w = FF_CEIL_RSHIFT(w, hshift); | 
																 | 
																 | 
																                w = FF_CEIL_RSHIFT(w, hshift); | 
															
														
														
													
														
															
																 | 
																 | 
																                h = FF_CEIL_RSHIFT(h, vshift); | 
																 | 
																 | 
																                h = FF_CEIL_RSHIFT(h, vshift); | 
															
														
														
													
														
															
																 | 
																 | 
																            } | 
																 | 
																 | 
																            } | 
															
														
														
													
														
															
																 | 
																 | 
																            if (s->upscale_v & (1<<p)) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            if (s->upscale_v[p]) | 
															
														
														
													
														
															
																 | 
																 | 
																                h = (h+1)>>1; | 
																 | 
																 | 
																                h = (h+1)>>1; | 
															
														
														
													
														
															
																 | 
																 | 
																            av_assert0(w > 0); | 
																 | 
																 | 
																            av_assert0(w > 0); | 
															
														
														
													
														
															
																 | 
																 | 
																            for (i = 0; i < h; i++) { | 
																 | 
																 | 
																            for (i = 0; i < h; i++) { | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -2171,7 +2174,7 @@ the_end: | 
															
														
														
													
														
															
																 | 
																 | 
																            } | 
																 | 
																 | 
																            } | 
															
														
														
													
														
															
																 | 
																 | 
																        } | 
																 | 
																 | 
																        } | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																    if (s->upscale_v) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if (AV_RB32(s->upscale_v)) { | 
															
														
														
													
														
															
																 | 
																 | 
																        int p; | 
																 | 
																 | 
																        int p; | 
															
														
														
													
														
															
																 | 
																 | 
																        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || | 
																 | 
																 | 
																        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || | 
															
														
														
													
														
															
																 | 
																 | 
																                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  || | 
																 | 
																 | 
																                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  || | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -2192,7 +2195,7 @@ the_end: | 
															
														
														
													
														
															
																 | 
																 | 
																            uint8_t *dst; | 
																 | 
																 | 
																            uint8_t *dst; | 
															
														
														
													
														
															
																 | 
																 | 
																            int w = s->width; | 
																 | 
																 | 
																            int w = s->width; | 
															
														
														
													
														
															
																 | 
																 | 
																            int h = s->height; | 
																 | 
																 | 
																            int h = s->height; | 
															
														
														
													
														
															
																 | 
																 | 
																            if (!(s->upscale_v & (1<<p))) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            if (!s->upscale_v[p]) | 
															
														
														
													
														
															
																 | 
																 | 
																                continue; | 
																 | 
																 | 
																                continue; | 
															
														
														
													
														
															
																 | 
																 | 
																            if (p==1 || p==2) { | 
																 | 
																 | 
																            if (p==1 || p==2) { | 
															
														
														
													
														
															
																 | 
																 | 
																                w = FF_CEIL_RSHIFT(w, hshift); | 
																 | 
																 | 
																                w = FF_CEIL_RSHIFT(w, hshift); | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																	
																 | 
																
  |