Opened 12 years ago

Closed 9 years ago

#1216 closed defect (fixed)

AVImszh: broken output with rgb24 mode

Reported by: ami_stuff Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: mszh
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

decodes correctly with original codec

C:\>ffmpeg -i RGB24.avi out.avi
ffmpeg version N-39824-g7432bcf Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr 15 2012 02:20:32 with gcc 4.5.0 20100414 (Fedora MinGW 4.5.0-1.fc
14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snapshots/buil
d/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/snapshots/b
uild/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3 --enable-n
onfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-libvorbis
--enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-libopencor
e-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      51. 46.100 / 51. 46.100
  libavcodec     54. 14.101 / 54. 14.101
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 70.100 /  2. 70.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 11.100 /  0. 11.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, avi, from 'RGB24.avi':
  Duration: 00:00:00.12, start: 0.000000, bitrate: 46634 kb/s
    Stream #0:0: Video: mszh (MSZH / 0x485A534D), bgr24, 320x240, 25 tbr, 25 tbn
, 25 tbc
Incompatible pixel format 'bgr24' for codec 'mpeg4', auto-selecting format 'yuv4
20p'
[buffer @ 0x1dc1e00] w:320 h:240 pixfmt:bgr24 tb:1/1000000 sar:0/1 sws_param:fla
gs=2
[buffersink @ 0x1dc12e0] auto-inserting filter 'auto-inserted scale 0' between t
he filter 'src' and the filter 'out'
[scale @ 0x1dc1c20] w:320 h:240 fmt:bgr24 sar:0/1 -> w:320 h:240 fmt:yuv420p sar
:0/1 flags:0x4
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf54.3.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 320x240, q=2-31, 200
 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mszh -> mpeg4)
Press [q] to stop, [?] for help
frame=    3 fps=0.0 q=2.0 Lsize=      65kB time=00:00:00.12 bitrate=4437.7kbits/
s
video:59kB audio:0kB global headers:0kB muxing overhead 9.461948%

Attachments (3)

RGB24.avi (683.1 KB ) - added by ami_stuff 12 years ago.
RGB24_nocompr.avi (683.1 KB ) - added by ami_stuff 12 years ago.
rgb_1022.avi (2.3 MB ) - added by ami_stuff 11 years ago.

Change History (11)

by ami_stuff, 12 years ago

Attachment: RGB24.avi added

comment:1 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavcodec
Keywords: mszh added
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Works fine with mplayer -vc mszh

comment:2 by ami_stuff, 12 years ago

it looks like AVImszh codec always saves RGB24 data as uncompressed, even when "No Compress" option is turned off

lcldec.c:

   switch (avctx->codec_id) {
    case CODEC_ID_MSZH:
        switch (c->compression) {
        case COMP_MSZH:
+            if (c->imgtype != IMGTYPE_RGB24) {
            if (c->flags & FLAG_MULTITHREAD) {
                mthread_inlen = AV_RL32(encoded);
                mthread_inlen = FFMIN(mthread_inlen, len - 8);
                mthread_outlen = AV_RL32(encoded+4);
                mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
                mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
                if (mthread_outlen != mszh_dlen) {
                    av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
                           mthread_outlen, mszh_dlen);
                    return -1;
                }
                mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
                                        c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
                if (mthread_outlen != mszh_dlen) {
                    av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
                           mthread_outlen, mszh_dlen);
                    return -1;
                }
                encoded = c->decomp_buf;
                len = c->decomp_size;
            } else {
                mszh_dlen = mszh_decomp(encoded, len, c->decomp_buf, c->decomp_size);
                if (c->decomp_size != mszh_dlen) {
                    av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
                           c->decomp_size, mszh_dlen);
                    return -1;
                }
                encoded = c->decomp_buf;
                len = mszh_dlen;
            }
+            }

but these for some reason decodes correctly:

http://samples.mplayerhq.hu/V-codecs/mszh-zlib/mszh/mszh_rgb24.avi
http://samples.mplayerhq.hu/V-codecs/mszh-zlib/mszh/mszh_rgb24_nocomp.avi

by ami_stuff, 12 years ago

Attachment: RGB24_nocompr.avi added

comment:3 by ami_stuff, 12 years ago

this one seems to be rawvideo, not mszh:

C:\>ffmpeg -i mszh_rgb24.avi
ffmpeg version N-39881-gdcd207c Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr 17 2012 02:23:18 with gcc 4.5.0 20100414 (Fedora MinGW 4.5.0-1.fc
14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snapshots/buil
d/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/snapshots/b
uild/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3 --enable-n
onfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-libvorbis
--enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-libopencor
e-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      51. 46.100 / 51. 46.100
  libavcodec     54. 14.101 / 54. 14.101
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 70.100 /  2. 70.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 11.100 /  0. 11.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, avi, from 'mszh_rgb24.avi':
  Duration: 00:00:00.03, start: 0.000000, bitrate: 62360 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 352x240, 29.97 tbr, 29.97 tbn, 29.97 tb
c
At least one output file must be specified

on the other hand this rgb24 file seems to be compressed, so maybe it's a bug of AVImszh codec, not FFmpeg's decoder?

http://samples.mplayerhq.hu/V-codecs/mszh-zlib/mszh.avi

comment:4 by Elon Musk, 11 years ago

So it happens only with RGB24 colorspace?

comment:5 by Elon Musk, 11 years ago

Resolution: fixed
Status: openclosed

Reopen if this happens with other colorspaces.

comment:6 by ami_stuff, 11 years ago

Resolution: fixed
Status: closedreopened

comment:7 by ami_stuff, 11 years ago

attached rgb24 decodes incorrectly.

by ami_stuff, 11 years ago

Attachment: rgb_1022.avi added

comment:8 by Michael Niedermayer, 9 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.