Opened 5 years ago

Closed 5 years ago

#1656 closed defect (fixed)

AVRn (mjpeg): change field order for ntsc

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

Description

AVRn in ntsc mode needs change of field order, so probably check for MKTAG and "NTSC" string in the file should be aded.

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) {
+    if (avctx->field_order == AV_FIELD_BB || s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') && ntsc_string) {
        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;
}
C:\>ffmpeg -i ntsc.avi out.bmp
ffmpeg version N-43678-gceb8773 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 18 2012 02:22:03 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. 25.100 / 54. 25.100
  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, avi, from 'ntsc.avi':
  Duration: 00:00:00.10, start: 0.000000, bitrate: 6630 kb/s
    Stream #0:0: Video: mjpeg (AVRn / 0x6E525641), yuvj422p, 720x496, 10 tbr, 10
 tbn, 10 tbc
Output #0, image2, to 'out.bmp':
  Metadata:
    encoder         : Lavf54.25.100
    Stream #0:0: Video: bmp, bgr24, 720x496, q=2-31, 200 kb/s, 90k tbn, 10 tbc
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.10 bitrate=   0.0kbits/
s
video:1046kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000000
%

Attachments (2)

ntsc.avi (80.9 KB) - added by ami_stuff 5 years ago.
pal.avi (89.3 KB) - added by ami_stuff 5 years ago.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by ami_stuff

Changed 5 years ago by ami_stuff

comment:1 Changed 5 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords mjpeg AVrn AVID added
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

comment:2 Changed 5 years ago by ami_stuff

Also it would be good to add an possibility to change fields order manually as an ffmpeg's option (if this is not already possible) for codecs like mjpeg/dv/frwu/mpeg.

comment:3 Changed 5 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed

Fixed by you.

Note: See TracTickets for help on using tickets.