Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#1648 closed defect (fixed)

avdj (mjpeg): problem with ntsc interlaced

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

Description

"ntsc_interlaced.mov" decodes incorrectly (pal sample decodes ok)

C:\>ffmpeg -i ntsc_interlaced.mov out.bmp
ffmpeg version N-43634-g3d78170 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 17 2012 02:39:28 with gcc 4.5.0 (GCC) 20100414 (Fedora MinGW 4.5.
0-1.fc14)
  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 -lpthread' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snap
shots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/s
napshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-
libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      51. 70.100 / 51. 70.100
  libavcodec     54. 53.100 / 54. 53.100
  libavformat    54. 24.101 / 54. 24.101
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 10.100 /  3. 10.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ntsc_interlaced.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
  Duration: 00:00:00.06, start: 0.000000, bitrate: 22468 kb/s
    Stream #0:0(eng): Video: mjpeg (AVDJ / 0x4A445641), yuvj422p, 720x490, 22344
 kb/s, SAR 10:11 DAR 720:539, 15 fps, 15 tbr, 600 tbn, 600 tbc
    Metadata:
      handler_name    : Procedura obs│ugi skrˇtˇw danych Apple
Output #0, image2, to 'out.bmp':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    encoder         : Lavf54.24.101
    Stream #0:0(eng): Video: bmp, bgr24, 720x490 [SAR 10:11 DAR 720:539], q=2-31
, 200 kb/s, 90k tbn, 15 tbc
    Metadata:
      handler_name    : Procedura obs│ugi skrˇtˇw danych Apple
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> bmp)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.06 bitrate=   0.0kbits/
s
video:1034kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000000
%

Attachments (3)

ntsc_interlaced.mov (182.9 KB ) - added by ami_stuff 12 years ago.
pal_interlaced.mov (208.0 KB ) - added by ami_stuff 12 years ago.
ntsc.jpg (90.5 KB ) - added by ami_stuff 12 years ago.

Download all attachments as: .zip

Change History (8)

by ami_stuff, 12 years ago

Attachment: ntsc_interlaced.mov added

by ami_stuff, 12 years ago

Attachment: pal_interlaced.mov added

comment:1 by ami_stuff, 12 years ago

probably fields order should be inverted for ntsc sample

comment:2 by ami_stuff, 12 years ago

the solution could be to check for MKTAG and metadata for ntsc (1 - ntsc, 2 - pal - see "ntsc.jpg")

libavcodec/mjpegdec.c:

av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
{
    MJpegDecodeContext *s = avctx->priv_data;

    if (!s->picture_ptr)
        s->picture_ptr = &s->picture;
    avcodec_get_frame_defaults(&s->picture);


    s->avctx = avctx;
    ff_dsputil_init(&s->dsp, avctx);
    ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
    s->buffer_size   = 0;
    s->buffer        = NULL;
    s->start_code    = -1;
    s->first_picture = 1;
    s->org_height    = avctx->coded_height;
    avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;

    build_basic_mjpeg_vlc(s);

    if (s->extern_huff) {
        av_log(avctx, AV_LOG_INFO, "using external huffman table\n");
        init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8);
        if (ff_mjpeg_decode_dht(s)) {
            av_log(avctx, AV_LOG_ERROR,
                   "error using external huffman table, switching back to internal\n");
            build_basic_mjpeg_vlc(s);
        }
    }
-    if (avctx->field_order == AV_FIELD_BB || s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) { /* quicktime icefloe 019 */
+    if (avctx->field_order == AV_FIELD_BB || s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J') && ntsc_mode) { /* quicktime icefloe 019 */
        s->interlace_polarity = 1;           /* bottom field first */
        av_log(avctx, AV_LOG_DEBUG, "bottom field first\n");
    }
    if (avctx->codec->id == CODEC_ID_AMV)
        s->flipped = 1;

    return 0;
}

by ami_stuff, 12 years ago

Attachment: ntsc.jpg added

comment:3 by Carl Eugen Hoyos, 12 years ago

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

comment:4 by ami_stuff, 10 years ago

Resolution: fixed
Status: openclosed

comment:5 by Carl Eugen Hoyos, 10 years ago

Keywords: AVID added
Note: See TracTickets for help on using tickets.