Fixes Ticket896
Unified · Split
| @@ -337,7 +337,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) · 336 unmodified lines | ||
| 337 | 337 | return AVERROR_INVALIDDATA; |
| 338 | 338 | } |
| 339 | 339 | } else{ |
| 340 | − if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3) | |
| 340 | + if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && (nb_components==3 || nb_components==4)) | |
| 341 | 341 | s->rgb = 1; |
| 342 | 342 | else if (!s->lossless) |
| 343 | 343 | s->rgb = 0; |
| @@ -368,6 +368,15 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) · 24 unmodified lines | ||
| 368 | 368 | } |
| 369 | 369 | av_assert0(s->nb_components == 3); |
| 370 | 370 | break; |
| 371 | + case 0x11111111: | |
| 372 | + if (s->rgb) | |
| 373 | + s->avctx->pix_fmt = AV_PIX_FMT_ABGR; | |
| 374 | + else { | |
| 375 | + s->avctx->pix_fmt = /*s->cs_itu601 ?*/ AV_PIX_FMT_YUVA444P/* : AV_PIX_FMT_YUVJA444P*/; | |
| 376 | + s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; | |
| 377 | + } | |
| 378 | + av_assert0(s->nb_components == 4); | |
| 379 | + break; | |
| 371 | 380 | case 0x12121100: |
| 372 | 381 | case 0x22122100: |
| 373 | 382 | s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; |
| @@ -774,7 +783,7 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p · 400 unmodified lines | ||
| 774 | 783 | { |
| 775 | 784 | int i, mb_x, mb_y; |
| 776 | 785 | uint16_t (*buffer)[4]; |
| 777 | − int left[3], top[3], topleft[3]; | |
| 786 | + int left[4], top[4], topleft[4]; | |
| 778 | 787 | const int linesize = s->linesize[0]; |
| 779 | 788 | const int mask = (1 << s->bits) - 1; |
| 780 | 789 | int resync_mb_y = 0; |
| @@ -786,7 +795,7 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p · 5 unmodified lines | ||
| 786 | 795 | (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0])); |
| 787 | 796 | buffer = s->ljpeg_buffer; |
| 788 | 797 | |
| 789 | − for (i = 0; i < 3; i++) | |
| 798 | + for (i = 0; i < 4; i++) | |
| 790 | 799 | buffer[0][i] = 1 << (s->bits - 1); |
| 791 | 800 | |
| 792 | 801 | for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
| @@ -795,7 +804,7 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p · 2 unmodified lines | ||
| 795 | 804 | if (s->interlaced && s->bottom_field) |
| 796 | 805 | ptr += linesize >> 1; |
| 797 | 806 | |
| 798 | − for (i = 0; i < 3; i++) | |
| 807 | + for (i = 0; i < 4; i++) | |
| 799 | 808 | top[i] = left[i] = topleft[i] = buffer[0][i]; |
| 800 | 809 | |
| 801 | 810 | for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
| @@ -805,7 +814,7 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p · 3 unmodified lines | ||
| 805 | 814 | s->restart_count = s->restart_interval; |
| 806 | 815 | resync_mb_x = mb_x; |
| 807 | 816 | resync_mb_y = mb_y; |
| 808 | − for(i=0; i<3; i++) | |
| 817 | + for(i=0; i<4; i++) | |
| 809 | 818 | top[i] = left[i]= topleft[i]= 1 << (s->bits - 1); |
| 810 | 819 | } |
| 811 | 820 | if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x) |
| @@ -832,8 +841,14 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p · 20 unmodified lines | ||
| 832 | 841 | skip_bits(&s->gb, 16); /* skip RSTn */ |
| 833 | 842 | } |
| 834 | 843 | } |
| 835 | − | |
| 836 | − if (s->rct) { | |
| 844 | + if (s->nb_components == 4) { | |
| 845 | + for(i=0; i<nb_components; i++) { | |
| 846 | + int c= s->comp_index[i]; | |
| 847 | + for(mb_x = 0; mb_x < s->mb_width; mb_x++) { | |
| 848 | + ptr[4*mb_x+3-c] = buffer[mb_x][i]; | |
| 849 | + } | |
| 850 | + } | |
| 851 | + } else if (s->rct) { | |
| 837 | 852 | for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
| 838 | 853 | ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2); |
| 839 | 854 | ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1]; |
| @@ -867,7 +882,7 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, · 27 unmodified lines | ||
| 867 | 882 | |
| 868 | 883 | point_transform += bits - s->bits; |
| 869 | 884 | |
| 870 | − av_assert0(nb_components>=1 && nb_components<=3); | |
| 885 | + av_assert0(nb_components>=1 && nb_components<=4); | |
| 871 | 886 | |
| 872 | 887 | for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
| 873 | 888 | for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |