OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 15 Feb 2012 23:49:16 +0000 (00:49 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 16 Feb 2012 00:34:37 +0000 (01:34 +0100)
* qatar/master: (27 commits)
  ppc: Add ff_ prefix to nonstatic symbols
  sh4: Add ff_ prefix to nonstatic symbols
  mpegvideo: Add ff_ prefix to nonstatic functions
  rtjpeg: Add ff_ prefix to nonstatic symbols
  rv: Add ff_ prefix to nonstatic symbols
  vp56: Add ff_ prefix to nonstatic symbols
  vorbis: Add ff_ prefix to nonstatic symbols
  msmpeg4: Add ff_ prefix to nonstatic symbols
  vc1: Add ff_ prefix to nonstatic symbols
  msmpeg4: Add ff_ prefixes to nonstatic symbols
  snow: Add ff_ prefix to nonstatic symbols
  mpeg12: Add ff_ prefix to nonstatic symbols
  mpeg4: Add ff_ prefixes to nonstatic symbols
  lagarith: Add ff_ prefix to lag_rac_init
  libavcodec: Add ff_ prefix to j_rev_dct*
  dsputil: Add ff_ prefix to inv_zigzag_direct16
  libavcodec: Prefix fdct_ifast, fdct_ifast248
  dsputil: Add ff_ prefix to the dsputil*_init* functions
  libavcodec: Add ff_ prefix to some nonstatic symbols
  vlc/rl: Add ff_ prefix to the nonstatic symbols
  ...

Conflicts:
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/dnxhddec.c
libavcodec/ffv1.c
libavcodec/h263.h
libavcodec/h263dec.c
libavcodec/h264.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c
libavcodec/nuv.c
libavcodec/ppc/dsputil_ppc.c
libavcodec/proresdsp.c
libavcodec/svq3.c
libavcodec/version.h
libavformat/dv.h
libavformat/dvenc.c
libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
197 files changed:
1  2 
Changelog
libavcodec/4xm.c
libavcodec/Makefile
libavcodec/aacdec.c
libavcodec/aacenc.c
libavcodec/ac3dec.c
libavcodec/ac3enc.c
libavcodec/allcodecs.c
libavcodec/alpha/dsputil_alpha.c
libavcodec/alpha/mpegvideo_alpha.c
libavcodec/alsdec.c
libavcodec/apedec.c
libavcodec/arm/dsputil_init_arm.c
libavcodec/arm/mpegvideo_arm.c
libavcodec/arm/mpegvideo_arm.h
libavcodec/arm/mpegvideo_armv5te.c
libavcodec/arm/mpegvideo_iwmmxt.c
libavcodec/asv1.c
libavcodec/atrac.c
libavcodec/atrac.h
libavcodec/atrac1.c
libavcodec/atrac3.c
libavcodec/bfin/dsputil_bfin.c
libavcodec/bfin/mpegvideo_bfin.c
libavcodec/bink.c
libavcodec/binkaudio.c
libavcodec/bitstream.c
libavcodec/cavs.c
libavcodec/cavsdec.c
libavcodec/cook.c
libavcodec/dca.c
libavcodec/dct-test.c
libavcodec/dnxhddec.c
libavcodec/dnxhdenc.c
libavcodec/dsputil.c
libavcodec/dsputil.h
libavcodec/dv.c
libavcodec/eamad.c
libavcodec/eatgq.c
libavcodec/eatqi.c
libavcodec/error_resilience.c
libavcodec/faxcompr.c
libavcodec/ffv1.c
libavcodec/flvenc.c
libavcodec/fraps.c
libavcodec/get_bits.h
libavcodec/h261dec.c
libavcodec/h261enc.c
libavcodec/h263.c
libavcodec/h263.h
libavcodec/h263data.h
libavcodec/h263dec.c
libavcodec/h264.c
libavcodec/huffman.c
libavcodec/huffyuv.c
libavcodec/imc.c
libavcodec/indeo3.c
libavcodec/indeo5.c
libavcodec/intelh263dec.c
libavcodec/interplayvideo.c
libavcodec/intrax8.c
libavcodec/ituh263dec.c
libavcodec/ituh263enc.c
libavcodec/ivi_common.c
libavcodec/jvdec.c
libavcodec/lagarith.c
libavcodec/lagarithrac.c
libavcodec/lagarithrac.h
libavcodec/ljpegenc.c
libavcodec/mdec.c
libavcodec/mimic.c
libavcodec/mips/dsputil_mmi.c
libavcodec/mips/mpegvideo_mmi.c
libavcodec/mjpegdec.c
libavcodec/mjpegenc.c
libavcodec/mlpdec.c
libavcodec/motion-test.c
libavcodec/motionpixels.c
libavcodec/mpc7.c
libavcodec/mpc8.c
libavcodec/mpeg12.c
libavcodec/mpeg12enc.c
libavcodec/mpeg4data.h
libavcodec/mpeg4video.h
libavcodec/mpeg4videodec.c
libavcodec/mpeg4videoenc.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_common.h
libavcodec/mpegvideo_enc.c
libavcodec/msmpeg4.c
libavcodec/msmpeg4data.c
libavcodec/msmpeg4data.h
libavcodec/nellymoserdec.c
libavcodec/nellymoserenc.c
libavcodec/nuv.c
libavcodec/pngenc.c
libavcodec/ppc/dsputil_altivec.c
libavcodec/ppc/dsputil_altivec.h
libavcodec/ppc/dsputil_ppc.c
libavcodec/ppc/fdct_altivec.c
libavcodec/ppc/float_altivec.c
libavcodec/ppc/gmc_altivec.c
libavcodec/ppc/h264_altivec.c
libavcodec/ppc/idct_altivec.c
libavcodec/ppc/int_altivec.c
libavcodec/ppc/mpegvideo_altivec.c
libavcodec/ppc/vp8dsp_altivec.c
libavcodec/proresdec_lgpl.c
libavcodec/proresdsp.c
libavcodec/proresdsp.h
libavcodec/proresenc_kostya.c
libavcodec/ra288.c
libavcodec/rl.h
libavcodec/rtjpeg.c
libavcodec/rtjpeg.h
libavcodec/rv10.c
libavcodec/rv10enc.c
libavcodec/rv20enc.c
libavcodec/rv34.c
libavcodec/rv34data.h
libavcodec/rv40.c
libavcodec/sh4/dsputil_align.c
libavcodec/sh4/dsputil_sh4.c
libavcodec/sh4/dsputil_sh4.h
libavcodec/sh4/idct_sh4.c
libavcodec/smacker.c
libavcodec/snow.c
libavcodec/snow.h
libavcodec/snowdata.h
libavcodec/snowdec.c
libavcodec/snowenc.c
libavcodec/sparc/dsputil_vis.c
libavcodec/svq1dec.c
libavcodec/svq1enc.c
libavcodec/svq3.c
libavcodec/truemotion2.c
libavcodec/truespeech.c
libavcodec/twinvq.c
libavcodec/utils.c
libavcodec/utvideo.c
libavcodec/vble.c
libavcodec/vc1.c
libavcodec/vc1.h
libavcodec/vc1_parser.c
libavcodec/vc1data.c
libavcodec/vc1data.h
libavcodec/vc1dec.c
libavcodec/version.h
libavcodec/vorbis.h
libavcodec/vorbisdec.c
libavcodec/vp3.c
libavcodec/vp5.c
libavcodec/vp56.c
libavcodec/vp56data.c
libavcodec/vp56data.h
libavcodec/vp6.c
libavcodec/vp8.c
libavcodec/wma.c
libavcodec/wmaprodec.c
libavcodec/wmv2.c
libavcodec/wmv2enc.c
libavcodec/x86/dsputil_mmx.c
libavcodec/x86/dsputil_mmx.h
libavcodec/x86/dsputilenc_mmx.c
libavcodec/x86/motion_est_mmx.c
libavcodec/x86/mpegvideo_mmx.c
libavcodec/x86/mpegvideo_mmx_template.c
libavformat/aea.c
libavformat/aiffdec.c
libavformat/au.c
libavformat/avidec.c
libavformat/avs.c
libavformat/c93.c
libavformat/cutils.c
libavformat/dv.c
libavformat/dv.h
libavformat/dvenc.c
libavformat/internal.h
libavformat/isom.c
libavformat/isom.h
libavformat/matroskadec.c
libavformat/matroskaenc.c
libavformat/mmf.c
libavformat/mov.c
libavformat/movenc.c
libavformat/omadec.c
libavformat/pcm.c
libavformat/pcm.h
libavformat/pcmdec.c
libavformat/rsodec.c
libavformat/rtspdec.c
libavformat/sol.c
libavformat/soxdec.c
libavformat/voc.h
libavformat/vocdec.c
libavformat/wav.c

diff --cc Changelog
+++ b/Changelog
@@@ -1,58 -1,36 +1,59 @@@
  Entries are sorted chronologically from oldest to youngest within each release,
  releases are sorted from youngest to oldest.
  
 -version <next>:
 -
 -- XWD encoder and decoder
 -- Support for fragmentation in the mov/mp4 muxer
 -- ISMV (Smooth Streaming) muxer
 +version next:
 +- v408 Quicktime and Microsoft AYUV Uncompressed 4:4:4:4 encoder and decoder
 +- setfield filter
  - CDXL demuxer and decoder
+ - Apple ProRes encoder
  
  
 -version 0.8:
 -
 +version 0.10:
 +- Fixes: CVE-2011-3929, CVE-2011-3934, CVE-2011-3935, CVE-2011-3936,
 +         CVE-2011-3937, CVE-2011-3940, CVE-2011-3941, CVE-2011-3944,
 +         CVE-2011-3945, CVE-2011-3946, CVE-2011-3947, CVE-2011-3949,
 +         CVE-2011-3950, CVE-2011-3951, CVE-2011-3952
 +- v410 Quicktime Uncompressed 4:4:4 10-bit encoder and decoder
 +- SBaGen (SBG) binaural beats script demuxer
 +- OpenMG Audio muxer
 +- Timecode extraction in DV and MOV
 +- thumbnail video filter
 +- XML output in ffprobe
 +- asplit audio filter
 +- tinterlace video filter
 +- astreamsync audio filter
 +- amerge audio filter
 +- ISMV (Smooth Streaming) muxer
  - GSM audio parser
  - SMJPEG muxer
 -
 -
 -version 0.8_beta2:
 -
 +- XWD encoder and decoder
  - Automatic thread count based on detection number of (available) CPU cores
 -- Deprecate libpostproc. If desired, the switch --enable-postproc will
 -  enable it but it may be removed in a later Libav release.
 +- y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder
 +- ffprobe -show_error option
 +- Avid 1:1 10-bit RGB Packer codec
 +- v308 Quicktime Uncompressed 4:4:4 encoder and decoder
 +- yuv4 libquicktime packed 4:2:0 encoder and decoder
 +- ffprobe -show_frames option
 +- silencedetect audio filter
 +- ffprobe -show_program_version, -show_library_versions, -show_versions options
  - rv34: frame-level multi-threading
  - optimized iMDCT transform on x86 using SSE for for mpegaudiodec
 +- Improved PGS subtitle decoder
 +- dumpgraph option to lavfi device
 +- r210 and r10k encoders
 +- ffwavesynth decoder
 +- aviocat tool
 +- ffeval tool
  
  
 -version 0.8_beta1:
 +version 0.9:
  
 +- openal input device added
 +- boxblur filter added
  - BWF muxer
  - Flash Screen Video 2 decoder
 -- ffplay/ffprobe/ffserver renamed to avplay/avprobe/avserver
 -- ffmpeg deprecated, added avconv, which is almost the same for now, except
 +- lavfi input device added
 +- added avconv, which is almost the same for now, except
  for a few incompatible changes in the options, which will hopefully make them
  easier to use. The changes are:
      * The options placement is now strictly enforced! While in theory the
Simple merge
@@@ -329,10 -301,8 +329,11 @@@ OBJS-$(CONFIG_PNG_DECODER)             
  OBJS-$(CONFIG_PNG_ENCODER)             += png.o pngenc.o
  OBJS-$(CONFIG_PPM_DECODER)             += pnmdec.o pnm.o
  OBJS-$(CONFIG_PPM_ENCODER)             += pnmenc.o pnm.o
 -OBJS-$(CONFIG_PRORES_DECODER)          += proresdec.o proresdata.o proresdsp.o
 -OBJS-$(CONFIG_PRORES_ENCODER)          += proresenc.o proresdata.o proresdsp.o
 +OBJS-$(CONFIG_PRORES_DECODER)          += proresdec2.o
 +OBJS-$(CONFIG_PRORES_LGPL_DECODER)     += proresdec_lgpl.o proresdsp.o
 +OBJS-$(CONFIG_PRORES_ENCODER)          += proresenc_anatoliy.o
 +OBJS-$(CONFIG_PRORES_ANATOLIY_ENCODER) += proresenc_anatoliy.o
++OBJS-$(CONFIG_PRORES_KOSTYA_ENCODER)   += proresenc_kostya.o proresdata.o proresdsp.o
  OBJS-$(CONFIG_PTX_DECODER)             += ptx.o
  OBJS-$(CONFIG_QCELP_DECODER)           += qcelpdec.o celp_math.o         \
                                            celp_filters.o acelp_vectors.o \
Simple merge
Simple merge
Simple merge
@@@ -2464,10 -2467,8 +2464,10 @@@ av_cold int ff_ac3_encode_init(AVCodecC
          goto init_fail;
  
      avctx->coded_frame= avcodec_alloc_frame();
 +    if (!avctx->coded_frame)
 +        goto init_fail;
  
-     dsputil_init(&s->dsp, avctx);
+     ff_dsputil_init(&s->dsp, avctx);
      ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
  
      dprint_options(s);
@@@ -181,8 -169,6 +181,9 @@@ void avcodec_register_all(void
      REGISTER_ENCDEC  (PNG, png);
      REGISTER_ENCDEC  (PPM, ppm);
      REGISTER_ENCDEC  (PRORES, prores);
 +    REGISTER_ENCODER (PRORES_ANATOLIY, prores_anatoliy);
++    REGISTER_ENCODER (PRORES_KOSTYA, prores_kostya);
 +    REGISTER_DECODER (PRORES_LGPL, prores_lgpl);
      REGISTER_DECODER (PTX, ptx);
      REGISTER_DECODER (QDRAW, qdraw);
      REGISTER_DECODER (QPEG, qpeg);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -413,10 -390,10 +413,10 @@@ static av_cold int dnxhd_decode_close(A
      DNXHDContext *ctx = avctx->priv_data;
  
      if (ctx->picture.data[0])
 -        avctx->release_buffer(avctx, &ctx->picture);
 +        ff_thread_release_buffer(avctx, &ctx->picture);
-     free_vlc(&ctx->ac_vlc);
-     free_vlc(&ctx->dc_vlc);
-     free_vlc(&ctx->run_vlc);
+     ff_free_vlc(&ctx->ac_vlc);
+     ff_free_vlc(&ctx->dc_vlc);
+     ff_free_vlc(&ctx->run_vlc);
      return 0;
  }
  
Simple merge
@@@ -3201,3 -3155,3 +3201,8 @@@ av_cold void ff_dsputil_init(DSPContext
      ff_init_scantable_permutation(c->idct_permutation,
                                    c->idct_permutation_type);
  }
++
++av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
++{
++    ff_dsputil_init(c, avctx);
++}
@@@ -581,8 -580,8 +581,9 @@@ typedef struct DSPContext 
      op_fill_func fill_block_tab[2];
  } DSPContext;
  
- void dsputil_static_init(void);
- void dsputil_init(DSPContext* p, AVCodecContext *avctx);
+ void ff_dsputil_static_init(void);
+ void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx);
++attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
  
  int ff_check_alignment(void);
  
diff --cc libavcodec/dv.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -672,9 -659,7 +672,9 @@@ static av_cold int common_init(AVCodecC
      s->avctx= avctx;
      s->flags= avctx->flags;
  
-     dsputil_init(&s->dsp, avctx);
 +    avcodec_get_frame_defaults(&s->picture);
 +
+     ff_dsputil_init(&s->dsp, avctx);
  
      s->width = avctx->width;
      s->height= avctx->height;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -55,12 -55,12 +55,12 @@@ extern VLC ff_h263_cbpy_vlc
  
  extern RLTable ff_h263_rl_inter;
  
- extern RLTable rl_intra_aic;
+ extern RLTable ff_rl_intra_aic;
  
- extern const uint16_t h263_format[8][2];
- extern const uint8_t modified_quant_tab[2][32];
+ extern const uint16_t ff_h263_format[8][2];
+ extern const uint8_t ff_modified_quant_tab[2][32];
 -extern uint16_t ff_mba_max[6];
 -extern uint8_t ff_mba_length[7];
 +extern const uint16_t ff_mba_max[6];
 +extern const uint8_t ff_mba_length[7];
  
  extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
  
Simple merge
@@@ -584,14 -571,8 +584,14 @@@ retry
          || s->height != avctx->coded_height) {
          /* H.263 could change picture size any time */
          ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
 +
 +        if (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME)) {
 +            av_log_missing_feature(s->avctx, "Width/height/bit depth/chroma idc changing with threads is", 0);
 +            return -1;   // width / height changed during parallelized decoding
 +        }
 +
          s->parse_context.buffer=0;
-         MPV_common_end(s);
+         ff_MPV_common_end(s);
          s->parse_context= pc;
      }
      if (!s->context_initialized) {
@@@ -1050,8 -1037,7 +1050,8 @@@ static av_cold void common_init(H264Con
      h->dequant_coeff_pps= -1;
      s->unrestricted_mv=1;
  
-     dsputil_init(&s->dsp, s->avctx); // needed so that idct permutation is known early
 +    s->dsp.dct_bits = 16;
+     ff_dsputil_init(&s->dsp, s->avctx); // needed so that idct permutation is known early
  
      memset(h->pps.scaling_matrix4, 16, 6*16*sizeof(uint8_t));
      memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
@@@ -2720,8 -2734,7 +2720,8 @@@ static int decode_slice_header(H264Cont
          }
          free_tables(h, 0);
          flush_dpb(s->avctx);
-         MPV_common_end(s);
+         ff_MPV_common_end(s);
 +        h->list_count = 0;
      }
      if (!s->context_initialized) {
          if (h != h0) {
          s->avctx->sample_aspect_ratio= h->sps.sar;
          av_assert0(s->avctx->sample_aspect_ratio.den);
  
-                 dsputil_init(&s->dsp, s->avctx);
 +        if (s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
 +            h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
 +            if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10 &&
 +                (h->sps.bit_depth_luma != 9 || !CHROMA422)) {
 +                s->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
 +                h->cur_chroma_format_idc = h->sps.chroma_format_idc;
 +                h->pixel_shift = h->sps.bit_depth_luma > 8;
 +
 +                ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma, h->sps.chroma_format_idc);
 +                ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc);
 +                s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
++                ff_dsputil_init(&s->dsp, s->avctx);
 +            } else {
 +                av_log(s->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d chroma_idc: %d\n",
 +                       h->sps.bit_depth_luma, h->sps.chroma_format_idc);
 +                return -1;
 +            }
 +        }
 +
          if(h->sps.video_signal_type_present_flag){
 -            s->avctx->color_range = h->sps.full_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
 +            s->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
              if(h->sps.colour_description_present_flag){
                  s->avctx->color_primaries = h->sps.color_primaries;
                  s->avctx->color_trc       = h->sps.color_trc;
@@@ -4166,10 -4117,9 +4166,10 @@@ av_cold int ff_h264_decode_end(AVCodecC
      H264Context *h = avctx->priv_data;
      MpegEncContext *s = &h->s;
  
 +    ff_h264_remove_all_refs(h);
      ff_h264_free_context(h);
  
-     MPV_common_end(s);
+     ff_MPV_common_end(s);
  
  //    memset(h, 0, sizeof(H264Context));
  
Simple merge
Simple merge
Simple merge
@@@ -995,9 -990,11 +995,9 @@@ static av_cold int decode_init(AVCodecC
  
      build_requant_tab();
  
-     dsputil_init(&ctx->dsp, avctx);
+     ff_dsputil_init(&ctx->dsp, avctx);
  
 -    allocate_frame_buffers(ctx, avctx);
 -
 -    return 0;
 +    return allocate_frame_buffers(ctx, avctx);
  }
  
  
Simple merge
Simple merge
@@@ -1017,12 -1017,8 +1017,12 @@@ static av_cold int ipvideo_decode_init(
      s->is_16bpp = avctx->bits_per_coded_sample == 16;
      avctx->pix_fmt = s->is_16bpp ? PIX_FMT_RGB555 : PIX_FMT_PAL8;
  
-     dsputil_init(&s->dsp, avctx);
+     ff_dsputil_init(&s->dsp, avctx);
  
 +    avcodec_get_frame_defaults(&s->second_last_frame);
 +    avcodec_get_frame_defaults(&s->last_frame);
 +    avcodec_get_frame_defaults(&s->current_frame);
 +
      s->current_frame.data[0] = s->last_frame.data[0] =
      s->second_last_frame.data[0] = NULL;
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -89,10 -88,9 +89,10 @@@ av_cold int ff_mjpeg_decode_init(AVCode
  
      if (!s->picture_ptr)
          s->picture_ptr = &s->picture;
 +    avcodec_get_frame_defaults(&s->picture);
  
      s->avctx = avctx;
-     dsputil_init(&s->dsp, 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;
@@@ -450,28 -445,6 +450,28 @@@ void ff_mjpeg_encode_mb(MpegEncContext 
      s->i_tex_bits += get_bits_diff(s);
  }
  
-     return MPV_encode_picture(avctx,buf, buf_size, pic);
 +// maximum over s->mjpeg_vsample[i]
 +#define V_MAX 2
 +static int amv_encode_picture(AVCodecContext *avctx,
 +                       unsigned char *buf, int buf_size, void *data)
 +{
 +
 +    AVFrame* pic=data;
 +    MpegEncContext *s = avctx->priv_data;
 +    int i;
 +
 +    //CODEC_FLAG_EMU_EDGE have to be cleared
 +    if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
 +        return -1;
 +
 +    //picture should be flipped upside-down
 +    for(i=0; i < 3; i++) {
 +        pic->data[i] += (pic->linesize[i] * (s->mjpeg_vsample[i] * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
 +        pic->linesize[i] *= -1;
 +    }
++    return ff_MPV_encode_picture(avctx,buf, buf_size, pic);
 +}
 +
  AVCodec ff_mjpeg_encoder = {
      .name           = "mjpeg",
      .type           = AVMEDIA_TYPE_VIDEO,
      .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE},
      .long_name= NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
  };
-     .init           = MPV_encode_init,
 +
 +AVCodec ff_amv_encoder = {
 +    .name           = "amv",
 +    .type           = AVMEDIA_TYPE_VIDEO,
 +    .id             = CODEC_ID_AMV,
 +    .priv_data_size = sizeof(MpegEncContext),
-     .close          = MPV_encode_end,
++    .init           = ff_MPV_encode_init,
 +    .encode         = amv_encode_picture,
++    .close          = ff_MPV_encode_end,
 +    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE},
 +    .long_name      = NULL_IF_CONFIG_SMALL("AMV Video"),
 +};
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -2074,8 -2037,10 +2074,8 @@@ static int vcr2_init_sequence(AVCodecCo
          if (avctx->idct_algo == FF_IDCT_AUTO)
              avctx->idct_algo = FF_IDCT_SIMPLE;
  
-     if (MPV_common_init(s) < 0)
+     if (ff_MPV_common_init(s) < 0)
          return -1;
 -    exchange_uv(s); // common init reset pblocks, so we swap them here
 -    s->swap_uv = 1; // in case of xvmc we need to swap uv for each MB
      s1->mpeg_enc_ctx_allocated = 1;
  
      for (i = 0; i < 64; i++) {
@@@ -966,11 -954,11 +966,11 @@@ AVCodec ff_mpeg1video_encoder = 
      .id             = CODEC_ID_MPEG1VIDEO,
      .priv_data_size = sizeof(MpegEncContext),
      .init           = encode_init,
-     .encode         = MPV_encode_picture,
-     .close          = MPV_encode_end,
+     .encode         = ff_MPV_encode_picture,
+     .close          = ff_MPV_encode_end,
      .supported_framerates= avpriv_frame_rate_tab+1,
      .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
 -    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
 +    .capabilities= CODEC_CAP_DELAY,
      .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
      .priv_class     = &mpeg1_class,
  };
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -541,11 -541,9 +541,11 @@@ int ff_mpeg_update_thread_context(AVCod
          s->bitstream_buffer      = NULL;
          s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
  
 -        ff_MPV_common_init(s);
 +        if (s1->context_initialized){
 +            s->picture_range_start  += MAX_PICTURE_COUNT;
 +            s->picture_range_end    += MAX_PICTURE_COUNT;
-             MPV_common_init(s);
++            ff_MPV_common_init(s);
 +        }
      }
  
      s->avctx->coded_height  = s1->avctx->coded_height;
Simple merge
Simple merge
@@@ -664,13 -657,13 +664,13 @@@ av_cold int ff_MPV_encode_init(AVCodecC
          break;
      case CODEC_ID_H263:
          if (!CONFIG_H263_ENCODER)
 -        return -1;
 +            return -1;
-         if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format),
+         if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),
                               s->width, s->height) == 8) {
 -            av_log(avctx, AV_LOG_INFO,
 +            av_log(avctx, AV_LOG_ERROR,
                     "The specified picture size of %dx%d is not valid for "
                     "the H.263 codec.\nValid sizes are 128x96, 176x144, "
 -                   "352x288, 704x576, and 1408x1152."
 +                   "352x288, 704x576, and 1408x1152. "
                     "Try H.263+.\n", s->width, s->height);
              return -1;
          }
@@@ -2031,10 -2020,9 +2031,10 @@@ static av_always_inline void encode_mb_
      case CODEC_ID_RV10:
      case CODEC_ID_RV20:
          if (CONFIG_H263_ENCODER)
-             h263_encode_mb(s, s->block, motion_x, motion_y);
+             ff_h263_encode_mb(s, s->block, motion_x, motion_y);
          break;
      case CODEC_ID_MJPEG:
 +    case CODEC_ID_AMV:
          if (CONFIG_MJPEG_ENCODER)
              ff_mjpeg_encode_mb(s, s->block);
          break;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -113,23 -112,19 +113,23 @@@ static int codec_reinit(AVCodecContext 
      if (quality >= 0)
          get_quant_quality(c, quality);
      if (width != c->width || height != c->height) {
 -        if (av_image_check_size(height, width, 0, avctx) < 0)
 -            return 0;
 +        // also reserve space for a possible additional header
 +        int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
 +        if (av_image_check_size(height, width, 0, avctx) < 0 ||
 +            buf_size > INT_MAX/8)
 +            return -1;
          avctx->width = c->width = width;
          avctx->height = c->height = height;
 -        av_fast_malloc(&c->decomp_buf, &c->decomp_size, c->height * c->width * 3 / 2);
 +        av_fast_malloc(&c->decomp_buf, &c->decomp_size, buf_size);
          if (!c->decomp_buf) {
              av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
 -            return 0;
 +            return AVERROR(ENOMEM);
          }
-         rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
+         ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
 +        return 1;
      } else if (quality != c->quality)
-         rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
+         ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
 -    return 1;
 +    return 0;
  }
  
  static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
@@@ -272,8 -258,8 +272,8 @@@ static av_cold int decode_init(AVCodecC
      c->codec_frameheader = avctx->codec_tag == MKTAG('R', 'J', 'P', 'G');
      if (avctx->extradata_size)
          get_quant(avctx, c, avctx->extradata, avctx->extradata_size);
-     dsputil_init(&c->dsp, avctx);
+     ff_dsputil_init(&c->dsp, avctx);
 -    if (!codec_reinit(avctx, avctx->width, avctx->height, -1))
 +    if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
          return 1;
      return 0;
  }
Simple merge
Simple merge
Simple merge
@@@ -143,17 -143,9 +143,17 @@@ static void prefetch_ppc(void *mem, in
      } while(--h);
  }
  
- void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
+ void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
  {
      const int high_bit_depth = avctx->bits_per_raw_sample > 8;
 +    int mm_flags = av_get_cpu_flags();
 +
 +    if (avctx->dsp_mask) {
 +        if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
 +            mm_flags |= (avctx->dsp_mask & 0xffff);
 +        else
 +            mm_flags &= ~(avctx->dsp_mask & 0xffff);
 +    }
  
      // Common optimizations whether AltiVec is available or not
      c->prefetch = prefetch_ppc;
      }
  
  #if HAVE_ALTIVEC
-     if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx);
+     if(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(c, avctx);
  
 -    if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
 +    if (mm_flags & AV_CPU_FLAG_ALTIVEC) {
-         dsputil_init_altivec(c, avctx);
-         float_init_altivec(c, avctx);
-         int_init_altivec(c, avctx);
-         c->gmc1 = gmc1_altivec;
+         ff_dsputil_init_altivec(c, avctx);
+         ff_float_init_altivec(c, avctx);
+         ff_int_init_altivec(c, avctx);
+         c->gmc1 = ff_gmc1_altivec;
  
  #if CONFIG_ENCODERS
          if (avctx->bits_per_raw_sample <= 8 &&
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -51,12 -51,27 +51,27 @@@ static void prores_idct_put_c(uint16_t 
      put_pixels(out, linesize >> 1, block);
  }
  
 -void ff_proresdsp_init(ProresDSPContext *dsp)
+ static void prores_fdct_c(const uint16_t *src, int linesize, DCTELEM *block)
+ {
+     int x, y;
+     const uint16_t *tsrc = src;
+     for (y = 0; y < 8; y++) {
+         for (x = 0; x < 8; x++)
+             block[y * 8 + x] = tsrc[x];
+         tsrc += linesize >> 1;
+     }
+     ff_jpeg_fdct_islow_10(block);
+ }
 +void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
  {
      dsp->idct_put = prores_idct_put_c;
      dsp->idct_permutation_type = FF_NO_IDCT_PERM;
+     dsp->fdct     = prores_fdct_c;
+     dsp->dct_permutation_type  = FF_NO_IDCT_PERM;
  
 -    if (HAVE_MMX) ff_proresdsp_x86_init(dsp);
 +    if (HAVE_MMX) ff_proresdsp_x86_init(dsp, avctx);
  
      ff_init_scantable_permutation(dsp->idct_permutation,
                                    dsp->idct_permutation_type);
  typedef struct {
      int idct_permutation_type;
      uint8_t idct_permutation[64];
+     int dct_permutation_type;
+     uint8_t dct_permutation[64];
      void (* idct_put) (uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat);
+     void (* fdct) (const uint16_t *src, int linesize, DCTELEM *block);
  } ProresDSPContext;
  
 -void ff_proresdsp_init(ProresDSPContext *dsp);
 +void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx);
  
 -void ff_proresdsp_x86_init(ProresDSPContext *dsp);
 +void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx);
  
  #endif /* AVCODEC_PRORESDSP_H */
index 0000000,c41982f..2937355
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,836 +1,836 @@@
 -    ff_proresdsp_init(&ctx->dsp);
+ /*
+  * Apple ProRes encoder
+  *
+  * Copyright (c) 2012 Konstantin Shishkov
+  *
+  * This file is part of Libav.
+  *
+  * Libav is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
+  * Libav is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with Libav; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "libavutil/opt.h"
+ #include "avcodec.h"
+ #include "put_bits.h"
+ #include "bytestream.h"
+ #include "internal.h"
+ #include "proresdsp.h"
+ #include "proresdata.h"
+ #define CFACTOR_Y422 2
+ #define CFACTOR_Y444 3
+ #define MAX_MBS_PER_SLICE 8
+ #define MAX_PLANES 3 // should be increased to 4 when there's PIX_FMT_YUV444AP10
+ enum {
+     PRORES_PROFILE_PROXY = 0,
+     PRORES_PROFILE_LT,
+     PRORES_PROFILE_STANDARD,
+     PRORES_PROFILE_HQ,
+ };
+ #define NUM_MB_LIMITS 4
+ static const int prores_mb_limits[NUM_MB_LIMITS] = {
+     1620, // up to 720x576
+     2700, // up to 960x720
+     6075, // up to 1440x1080
+     9216, // up to 2048x1152
+ };
+ static const struct prores_profile {
+     const char *full_name;
+     uint32_t    tag;
+     int         min_quant;
+     int         max_quant;
+     int         br_tab[NUM_MB_LIMITS];
+     uint8_t     quant[64];
+ } prores_profile_info[4] = {
+     {
+         .full_name = "proxy",
+         .tag       = MKTAG('a', 'p', 'c', 'o'),
+         .min_quant = 4,
+         .max_quant = 8,
+         .br_tab    = { 300, 242, 220, 194 },
+         .quant     = {
+              4,  7,  9, 11, 13, 14, 15, 63,
+              7,  7, 11, 12, 14, 15, 63, 63,
+              9, 11, 13, 14, 15, 63, 63, 63,
+             11, 11, 13, 14, 63, 63, 63, 63,
+             11, 13, 14, 63, 63, 63, 63, 63,
+             13, 14, 63, 63, 63, 63, 63, 63,
+             13, 63, 63, 63, 63, 63, 63, 63,
+             63, 63, 63, 63, 63, 63, 63, 63,
+         },
+     },
+     {
+         .full_name = "LT",
+         .tag       = MKTAG('a', 'p', 'c', 's'),
+         .min_quant = 1,
+         .max_quant = 9,
+         .br_tab    = { 720, 560, 490, 440 },
+         .quant     = {
+              4,  5,  6,  7,  9, 11, 13, 15,
+              5,  5,  7,  8, 11, 13, 15, 17,
+              6,  7,  9, 11, 13, 15, 15, 17,
+              7,  7,  9, 11, 13, 15, 17, 19,
+              7,  9, 11, 13, 14, 16, 19, 23,
+              9, 11, 13, 14, 16, 19, 23, 29,
+              9, 11, 13, 15, 17, 21, 28, 35,
+             11, 13, 16, 17, 21, 28, 35, 41,
+         },
+     },
+     {
+         .full_name = "standard",
+         .tag       = MKTAG('a', 'p', 'c', 'n'),
+         .min_quant = 1,
+         .max_quant = 6,
+         .br_tab    = { 1050, 808, 710, 632 },
+         .quant     = {
+              4,  4,  5,  5,  6,  7,  7,  9,
+              4,  4,  5,  6,  7,  7,  9,  9,
+              5,  5,  6,  7,  7,  9,  9, 10,
+              5,  5,  6,  7,  7,  9,  9, 10,
+              5,  6,  7,  7,  8,  9, 10, 12,
+              6,  7,  7,  8,  9, 10, 12, 15,
+              6,  7,  7,  9, 10, 11, 14, 17,
+              7,  7,  9, 10, 11, 14, 17, 21,
+         },
+     },
+     {
+         .full_name = "high quality",
+         .tag       = MKTAG('a', 'p', 'c', 'h'),
+         .min_quant = 1,
+         .max_quant = 6,
+         .br_tab    = { 1566, 1216, 1070, 950 },
+         .quant     = {
+              4,  4,  4,  4,  4,  4,  4,  4,
+              4,  4,  4,  4,  4,  4,  4,  4,
+              4,  4,  4,  4,  4,  4,  4,  4,
+              4,  4,  4,  4,  4,  4,  4,  5,
+              4,  4,  4,  4,  4,  4,  5,  5,
+              4,  4,  4,  4,  4,  5,  5,  6,
+              4,  4,  4,  4,  5,  5,  6,  7,
+              4,  4,  4,  4,  5,  6,  7,  7,
+         },
+     }
+ // for 4444 profile bitrate numbers are { 2350, 1828, 1600, 1425 }
+ };
+ #define TRELLIS_WIDTH 16
+ #define SCORE_LIMIT   INT_MAX / 2
+ struct TrellisNode {
+     int prev_node;
+     int quant;
+     int bits;
+     int score;
+ };
+ typedef struct ProresContext {
+     AVClass *class;
+     DECLARE_ALIGNED(16, DCTELEM, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
+     DECLARE_ALIGNED(16, uint16_t, emu_buf)[16*16];
+     int16_t quants[16][64];
+     ProresDSPContext dsp;
+     ScanTable  scantable;
+     int mb_width, mb_height;
+     int mbs_per_slice;
+     int num_chroma_blocks, chroma_factor;
+     int slices_width;
+     int num_slices;
+     int num_planes;
+     int bits_per_mb;
+     int profile;
+     const struct prores_profile *profile_info;
+     struct TrellisNode *nodes;
+     int *slice_q;
+ } ProresContext;
+ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
+                            int linesize, int x, int y, int w, int h,
+                            DCTELEM *blocks,
+                            int mbs_per_slice, int blocks_per_mb)
+ {
+     const uint16_t *esrc;
+     const int mb_width = 4 * blocks_per_mb;
+     int elinesize;
+     int i, j, k;
+     for (i = 0; i < mbs_per_slice; i++, src += mb_width) {
+         if (x >= w) {
+             memset(blocks, 0, 64 * (mbs_per_slice - i) * blocks_per_mb
+                               * sizeof(*blocks));
+             return;
+         }
+         if (x + mb_width <= w && y + 16 <= h) {
+             esrc      = src;
+             elinesize = linesize;
+         } else {
+             int bw, bh, pix;
+             const int estride = 16 / sizeof(*ctx->emu_buf);
+             esrc      = ctx->emu_buf;
+             elinesize = 16;
+             bw = FFMIN(w - x, mb_width);
+             bh = FFMIN(h - y, 16);
+             for (j = 0; j < bh; j++) {
+                 memcpy(ctx->emu_buf + j * estride, src + j * linesize,
+                        bw * sizeof(*src));
+                 pix = ctx->emu_buf[j * estride + bw - 1];
+                 for (k = bw; k < mb_width; k++)
+                     ctx->emu_buf[j * estride + k] = pix;
+             }
+             for (; j < 16; j++)
+                 memcpy(ctx->emu_buf + j * estride,
+                        ctx->emu_buf + (bh - 1) * estride,
+                        mb_width * sizeof(*ctx->emu_buf));
+         }
+         ctx->dsp.fdct(esrc, elinesize, blocks);
+         blocks += 64;
+         if (blocks_per_mb > 2) {
+             ctx->dsp.fdct(src + 8, linesize, blocks);
+             blocks += 64;
+         }
+         ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
+         blocks += 64;
+         if (blocks_per_mb > 2) {
+             ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
+             blocks += 64;
+         }
+         x += mb_width;
+     }
+ }
+ /**
+  * Write an unsigned rice/exp golomb codeword.
+  */
+ static inline void encode_vlc_codeword(PutBitContext *pb, uint8_t codebook, int val)
+ {
+     unsigned int rice_order, exp_order, switch_bits, switch_val;
+     int exponent;
+     /* number of prefix bits to switch between Rice and expGolomb */
+     switch_bits = (codebook & 3) + 1;
+     rice_order  =  codebook >> 5;       /* rice code order */
+     exp_order   = (codebook >> 2) & 7;  /* exp golomb code order */
+     switch_val  = switch_bits << rice_order;
+     if (val >= switch_val) {
+         val -= switch_val - (1 << exp_order);
+         exponent = av_log2(val);
+         put_bits(pb, exponent - exp_order + switch_bits, 0);
+         put_bits(pb, 1, 1);
+         put_bits(pb, exponent, val);
+     } else {
+         exponent = val >> rice_order;
+         if (exponent)
+             put_bits(pb, exponent, 0);
+         put_bits(pb, 1, 1);
+         if (rice_order)
+             put_sbits(pb, rice_order, val);
+     }
+ }
+ #define GET_SIGN(x)  ((x) >> 31)
+ #define MAKE_CODE(x) (((x) << 1) ^ GET_SIGN(x))
+ static void encode_dcs(PutBitContext *pb, DCTELEM *blocks,
+                        int blocks_per_slice, int scale)
+ {
+     int i;
+     int codebook = 3, code, dc, prev_dc, delta, sign, new_sign;
+     prev_dc = (blocks[0] - 0x4000) / scale;
+     encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
+     codebook = 3;
+     blocks  += 64;
+     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
+         dc       = (blocks[0] - 0x4000) / scale;
+         delta    = dc - prev_dc;
+         new_sign = GET_SIGN(delta);
+         delta    = (delta ^ sign) - sign;
+         code     = MAKE_CODE(delta);
+         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
+         codebook = (code + (code & 1)) >> 1;
+         codebook = FFMIN(codebook, 3);
+         sign     = new_sign;
+         prev_dc  = dc;
+     }
+ }
+ static void encode_acs(PutBitContext *pb, DCTELEM *blocks,
+                        int blocks_per_slice,
+                        int plane_size_factor,
+                        const uint8_t *scan, const int16_t *qmat)
+ {
+     int idx, i;
+     int run, level, run_cb, lev_cb;
+     int max_coeffs, abs_level;
+     max_coeffs = blocks_per_slice << 6;
+     run_cb     = ff_prores_run_to_cb_index[4];
+     lev_cb     = ff_prores_lev_to_cb_index[2];
+     run        = 0;
+     for (i = 1; i < 64; i++) {
+         for (idx = scan[i]; idx < max_coeffs; idx += 64) {
+             level = blocks[idx] / qmat[scan[i]];
+             if (level) {
+                 abs_level = FFABS(level);
+                 encode_vlc_codeword(pb, ff_prores_ac_codebook[run_cb], run);
+                 encode_vlc_codeword(pb, ff_prores_ac_codebook[lev_cb],
+                                     abs_level - 1);
+                 put_sbits(pb, 1, GET_SIGN(level));
+                 run_cb = ff_prores_run_to_cb_index[FFMIN(run, 15)];
+                 lev_cb = ff_prores_lev_to_cb_index[FFMIN(abs_level, 9)];
+                 run    = 0;
+             } else {
+                 run++;
+             }
+         }
+     }
+ }
+ static int encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
+                               const uint16_t *src, int linesize,
+                               int mbs_per_slice, DCTELEM *blocks,
+                               int blocks_per_mb, int plane_size_factor,
+                               const int16_t *qmat)
+ {
+     int blocks_per_slice, saved_pos;
+     saved_pos = put_bits_count(pb);
+     blocks_per_slice = mbs_per_slice * blocks_per_mb;
+     encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
+     encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
+                ctx->scantable.permutated, qmat);
+     flush_put_bits(pb);
+     return (put_bits_count(pb) - saved_pos) >> 3;
+ }
+ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
+                         PutBitContext *pb,
+                         int sizes[4], int x, int y, int quant,
+                         int mbs_per_slice)
+ {
+     ProresContext *ctx = avctx->priv_data;
+     int i, xp, yp;
+     int total_size = 0;
+     const uint16_t *src;
+     int slice_width_factor = av_log2(mbs_per_slice);
+     int num_cblocks, pwidth;
+     int plane_factor, is_chroma;
+     for (i = 0; i < ctx->num_planes; i++) {
+         is_chroma    = (i == 1 || i == 2);
+         plane_factor = slice_width_factor + 2;
+         if (is_chroma)
+             plane_factor += ctx->chroma_factor - 3;
+         if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {
+             xp          = x << 4;
+             yp          = y << 4;
+             num_cblocks = 4;
+             pwidth      = avctx->width;
+         } else {
+             xp          = x << 3;
+             yp          = y << 4;
+             num_cblocks = 2;
+             pwidth      = avctx->width >> 1;
+         }
+         src = (const uint16_t*)(pic->data[i] + yp * pic->linesize[i]) + xp;
+         get_slice_data(ctx, src, pic->linesize[i], xp, yp,
+                        pwidth, avctx->height, ctx->blocks[0],
+                        mbs_per_slice, num_cblocks);
+         sizes[i] = encode_slice_plane(ctx, pb, src, pic->linesize[i],
+                                       mbs_per_slice, ctx->blocks[0],
+                                       num_cblocks, plane_factor,
+                                       ctx->quants[quant]);
+         total_size += sizes[i];
+     }
+     return total_size;
+ }
+ static inline int estimate_vlc(uint8_t codebook, int val)
+ {
+     unsigned int rice_order, exp_order, switch_bits, switch_val;
+     int exponent;
+     /* number of prefix bits to switch between Rice and expGolomb */
+     switch_bits = (codebook & 3) + 1;
+     rice_order  =  codebook >> 5;       /* rice code order */
+     exp_order   = (codebook >> 2) & 7;  /* exp golomb code order */
+     switch_val  = switch_bits << rice_order;
+     if (val >= switch_val) {
+         val -= switch_val - (1 << exp_order);
+         exponent = av_log2(val);
+         return exponent * 2 - exp_order + switch_bits + 1;
+     } else {
+         return (val >> rice_order) + rice_order + 1;
+     }
+ }
+ static int estimate_dcs(int *error, DCTELEM *blocks, int blocks_per_slice,
+                         int scale)
+ {
+     int i;
+     int codebook = 3, code, dc, prev_dc, delta, sign, new_sign;
+     int bits;
+     prev_dc  = (blocks[0] - 0x4000) / scale;
+     bits     = estimate_vlc(FIRST_DC_CB, MAKE_CODE(prev_dc));
+     codebook = 3;
+     blocks  += 64;
+     *error  += FFABS(blocks[0] - 0x4000) % scale;
+     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
+         dc       = (blocks[0] - 0x4000) / scale;
+         *error  += FFABS(blocks[0] - 0x4000) % scale;
+         delta    = dc - prev_dc;
+         new_sign = GET_SIGN(delta);
+         delta    = (delta ^ sign) - sign;
+         code     = MAKE_CODE(delta);
+         bits    += estimate_vlc(ff_prores_dc_codebook[codebook], code);
+         codebook = (code + (code & 1)) >> 1;
+         codebook = FFMIN(codebook, 3);
+         sign     = new_sign;
+         prev_dc  = dc;
+     }
+     return bits;
+ }
+ static int estimate_acs(int *error, DCTELEM *blocks, int blocks_per_slice,
+                         int plane_size_factor,
+                         const uint8_t *scan, const int16_t *qmat)
+ {
+     int idx, i;
+     int run, level, run_cb, lev_cb;
+     int max_coeffs, abs_level;
+     int bits = 0;
+     max_coeffs = blocks_per_slice << 6;
+     run_cb     = ff_prores_run_to_cb_index[4];
+     lev_cb     = ff_prores_lev_to_cb_index[2];
+     run        = 0;
+     for (i = 1; i < 64; i++) {
+         for (idx = scan[i]; idx < max_coeffs; idx += 64) {
+             level   = blocks[idx] / qmat[scan[i]];
+             *error += FFABS(blocks[idx]) % qmat[scan[i]];
+             if (level) {
+                 abs_level = FFABS(level);
+                 bits += estimate_vlc(ff_prores_ac_codebook[run_cb], run);
+                 bits += estimate_vlc(ff_prores_ac_codebook[lev_cb],
+                                      abs_level - 1) + 1;
+                 run_cb = ff_prores_run_to_cb_index[FFMIN(run, 15)];
+                 lev_cb = ff_prores_lev_to_cb_index[FFMIN(abs_level, 9)];
+                 run    = 0;
+             } else {
+                 run++;
+             }
+         }
+     }
+     return bits;
+ }
+ static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
+                                 const uint16_t *src, int linesize,
+                                 int mbs_per_slice,
+                                 int blocks_per_mb, int plane_size_factor,
+                                 const int16_t *qmat)
+ {
+     int blocks_per_slice;
+     int bits;
+     blocks_per_slice = mbs_per_slice * blocks_per_mb;
+     bits  = estimate_dcs(error, ctx->blocks[plane], blocks_per_slice, qmat[0]);
+     bits += estimate_acs(error, ctx->blocks[plane], blocks_per_slice,
+                          plane_size_factor, ctx->scantable.permutated, qmat);
+     return FFALIGN(bits, 8);
+ }
+ static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic,
+                             int trellis_node, int x, int y, int mbs_per_slice)
+ {
+     ProresContext *ctx = avctx->priv_data;
+     int i, q, pq, xp, yp;
+     const uint16_t *src;
+     int slice_width_factor = av_log2(mbs_per_slice);
+     int num_cblocks[MAX_PLANES], pwidth;
+     int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];
+     const int min_quant = ctx->profile_info->min_quant;
+     const int max_quant = ctx->profile_info->max_quant;
+     int error, bits, bits_limit;
+     int mbs, prev, cur, new_score;
+     int slice_bits[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];
+     mbs = x + mbs_per_slice;
+     for (i = 0; i < ctx->num_planes; i++) {
+         is_chroma[i]    = (i == 1 || i == 2);
+         plane_factor[i] = slice_width_factor + 2;
+         if (is_chroma[i])
+             plane_factor[i] += ctx->chroma_factor - 3;
+         if (!is_chroma[i] || ctx->chroma_factor == CFACTOR_Y444) {
+             xp             = x << 4;
+             yp             = y << 4;
+             num_cblocks[i] = 4;
+             pwidth         = avctx->width;
+         } else {
+             xp             = x << 3;
+             yp             = y << 4;
+             num_cblocks[i] = 2;
+             pwidth         = avctx->width >> 1;
+         }
+         src = (const uint16_t*)(pic->data[i] + yp * pic->linesize[i]) + xp;
+         get_slice_data(ctx, src, pic->linesize[i], xp, yp,
+                        pwidth, avctx->height, ctx->blocks[i],
+                        mbs_per_slice, num_cblocks[i]);
+     }
+     for (q = min_quant; q <= max_quant; q++) {
+         ctx->nodes[trellis_node + q].prev_node = -1;
+         ctx->nodes[trellis_node + q].quant     = q;
+     }
+     // todo: maybe perform coarser quantising to fit into frame size when needed
+     for (q = min_quant; q <= max_quant; q++) {
+         bits  = 0;
+         error = 0;
+         for (i = 0; i < ctx->num_planes; i++) {
+             bits += estimate_slice_plane(ctx, &error, i,
+                                          src, pic->linesize[i],
+                                          mbs_per_slice,
+                                          num_cblocks[i], plane_factor[i],
+                                          ctx->quants[q]);
+         }
+         if (bits > 65000 * 8) {
+             error = SCORE_LIMIT;
+             break;
+         }
+         slice_bits[q]  = bits;
+         slice_score[q] = error;
+     }
+     bits_limit = mbs * ctx->bits_per_mb;
+     for (pq = min_quant; pq <= max_quant; pq++) {
+         prev = trellis_node - TRELLIS_WIDTH + pq;
+         for (q = min_quant; q <= max_quant; q++) {
+             cur = trellis_node + q;
+             bits  = ctx->nodes[prev].bits + slice_bits[q];
+             error = slice_score[q];
+             if (bits > bits_limit)
+                 error = SCORE_LIMIT;
+             if (ctx->nodes[prev].score < SCORE_LIMIT && error < SCORE_LIMIT)
+                 new_score = ctx->nodes[prev].score + error;
+             else
+                 new_score = SCORE_LIMIT;
+             if (ctx->nodes[cur].prev_node == -1 ||
+                 ctx->nodes[cur].score >= new_score) {
+                 ctx->nodes[cur].bits      = bits;
+                 ctx->nodes[cur].score     = new_score;
+                 ctx->nodes[cur].prev_node = prev;
+             }
+         }
+     }
+     error = ctx->nodes[trellis_node + min_quant].score;
+     pq    = trellis_node + min_quant;
+     for (q = min_quant + 1; q <= max_quant; q++) {
+         if (ctx->nodes[trellis_node + q].score <= error) {
+             error = ctx->nodes[trellis_node + q].score;
+             pq    = trellis_node + q;
+         }
+     }
+     return pq;
+ }
+ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+                         const AVFrame *pic, int *got_packet)
+ {
+     ProresContext *ctx = avctx->priv_data;
+     uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
+     uint8_t *picture_size_pos;
+     PutBitContext pb;
+     int x, y, i, mb, q = 0;
+     int sizes[4] = { 0 };
+     int slice_hdr_size = 2 + 2 * (ctx->num_planes - 1);
+     int frame_size, picture_size, slice_size;
+     int mbs_per_slice = ctx->mbs_per_slice;
+     int pkt_size, ret;
+     *avctx->coded_frame           = *pic;
+     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+     avctx->coded_frame->key_frame = 1;
+     pkt_size = ctx->mb_width * ctx->mb_height * 64 * 3 * 12
+                + ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;
+     if ((ret = ff_alloc_packet(pkt, pkt_size)) < 0) {
+         av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+         return ret;
+     }
+     orig_buf = pkt->data;
+     // frame atom
+     orig_buf += 4;                              // frame size
+     bytestream_put_be32  (&orig_buf, FRAME_ID); // frame container ID
+     buf = orig_buf;
+     // frame header
+     tmp = buf;
+     buf += 2;                                   // frame header size will be stored here
+     bytestream_put_be16  (&buf, 0);             // version 1
+     bytestream_put_buffer(&buf, "Lavc", 4);     // creator
+     bytestream_put_be16  (&buf, avctx->width);
+     bytestream_put_be16  (&buf, avctx->height);
+     bytestream_put_byte  (&buf, ctx->chroma_factor << 6); // frame flags
+     bytestream_put_byte  (&buf, 0);             // reserved
+     bytestream_put_byte  (&buf, 0);             // primaries
+     bytestream_put_byte  (&buf, 0);             // transfer function
+     bytestream_put_byte  (&buf, 6);             // colour matrix - ITU-R BT.601-4
+     bytestream_put_byte  (&buf, 0x40);          // source format and alpha information
+     bytestream_put_byte  (&buf, 0);             // reserved
+     bytestream_put_byte  (&buf, 0x03);          // matrix flags - both matrices are present
+     // luma quantisation matrix
+     for (i = 0; i < 64; i++)
+         bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
+     // chroma quantisation matrix
+     for (i = 0; i < 64; i++)
+         bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
+     bytestream_put_be16  (&tmp, buf - orig_buf); // write back frame header size
+     // picture header
+     picture_size_pos = buf + 1;
+     bytestream_put_byte  (&buf, 0x40);          // picture header size (in bits)
+     buf += 4;                                   // picture data size will be stored here
+     bytestream_put_be16  (&buf, ctx->num_slices); // total number of slices
+     bytestream_put_byte  (&buf, av_log2(ctx->mbs_per_slice) << 4); // slice width and height in MBs
+     // seek table - will be filled during slice encoding
+     slice_sizes = buf;
+     buf += ctx->num_slices * 2;
+     // slices
+     for (y = 0; y < ctx->mb_height; y++) {
+         mbs_per_slice = ctx->mbs_per_slice;
+         for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
+             while (ctx->mb_width - x < mbs_per_slice)
+                 mbs_per_slice >>= 1;
+             q = find_slice_quant(avctx, pic, (mb + 1) * TRELLIS_WIDTH, x, y,
+                                  mbs_per_slice);
+         }
+         for (x = ctx->slices_width - 1; x >= 0; x--) {
+             ctx->slice_q[x] = ctx->nodes[q].quant;
+             q = ctx->nodes[q].prev_node;
+         }
+         mbs_per_slice = ctx->mbs_per_slice;
+         for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
+             q = ctx->slice_q[mb];
+             while (ctx->mb_width - x < mbs_per_slice)
+                 mbs_per_slice >>= 1;
+             bytestream_put_byte(&buf, slice_hdr_size << 3);
+             slice_hdr = buf;
+             buf += slice_hdr_size - 1;
+             init_put_bits(&pb, buf, (pkt_size - (buf - orig_buf)) * 8);
+             encode_slice(avctx, pic, &pb, sizes, x, y, q, mbs_per_slice);
+             bytestream_put_byte(&slice_hdr, q);
+             slice_size = slice_hdr_size + sizes[ctx->num_planes - 1];
+             for (i = 0; i < ctx->num_planes - 1; i++) {
+                 bytestream_put_be16(&slice_hdr, sizes[i]);
+                 slice_size += sizes[i];
+             }
+             bytestream_put_be16(&slice_sizes, slice_size);
+             buf += slice_size - slice_hdr_size;
+         }
+     }
+     orig_buf -= 8;
+     frame_size = buf - orig_buf;
+     picture_size = buf - picture_size_pos - 6;
+     bytestream_put_be32(&orig_buf, frame_size);
+     bytestream_put_be32(&picture_size_pos, picture_size);
+     pkt->size   = frame_size;
+     pkt->flags |= AV_PKT_FLAG_KEY;
+     *got_packet = 1;
+     return 0;
+ }
+ static av_cold int encode_close(AVCodecContext *avctx)
+ {
+     ProresContext *ctx = avctx->priv_data;
+     if (avctx->coded_frame->data[0])
+         avctx->release_buffer(avctx, avctx->coded_frame);
+     av_freep(&avctx->coded_frame);
+     av_freep(&ctx->nodes);
+     av_freep(&ctx->slice_q);
+     return 0;
+ }
+ static av_cold int encode_init(AVCodecContext *avctx)
+ {
+     ProresContext *ctx = avctx->priv_data;
+     int mps;
+     int i, j;
+     int min_quant, max_quant;
+     avctx->bits_per_raw_sample = 10;
+     avctx->coded_frame = avcodec_alloc_frame();
+     if (!avctx->coded_frame)
+         return AVERROR(ENOMEM);
 -AVCodec ff_prores_encoder = {
 -    .name           = "prores",
++    ff_proresdsp_init(&ctx->dsp, avctx);
+     ff_init_scantable(ctx->dsp.dct_permutation, &ctx->scantable,
+                       ff_prores_progressive_scan);
+     mps = ctx->mbs_per_slice;
+     if (mps & (mps - 1)) {
+         av_log(avctx, AV_LOG_ERROR,
+                "there should be an integer power of two MBs per slice\n");
+         return AVERROR(EINVAL);
+     }
+     ctx->chroma_factor = avctx->pix_fmt == PIX_FMT_YUV422P10
+                          ? CFACTOR_Y422
+                          : CFACTOR_Y444;
+     ctx->profile_info  = prores_profile_info + ctx->profile;
+     ctx->num_planes    = 3;
+     ctx->mb_width      = FFALIGN(avctx->width,  16) >> 4;
+     ctx->mb_height     = FFALIGN(avctx->height, 16) >> 4;
+     ctx->slices_width  = ctx->mb_width / mps;
+     ctx->slices_width += av_popcount(ctx->mb_width - ctx->slices_width * mps);
+     ctx->num_slices    = ctx->mb_height * ctx->slices_width;
+     for (i = 0; i < NUM_MB_LIMITS - 1; i++)
+         if (prores_mb_limits[i] >= ctx->mb_width * ctx->mb_height)
+             break;
+     ctx->bits_per_mb   = ctx->profile_info->br_tab[i];
+     min_quant = ctx->profile_info->min_quant;
+     max_quant = ctx->profile_info->max_quant;
+     for (i = min_quant; i <= max_quant; i++) {
+         for (j = 0; j < 64; j++)
+             ctx->quants[i][j] = ctx->profile_info->quant[j] * i;
+     }
+     avctx->codec_tag   = ctx->profile_info->tag;
+     av_log(avctx, AV_LOG_DEBUG, "profile %d, %d slices, %d bits per MB\n",
+            ctx->profile, ctx->num_slices, ctx->bits_per_mb);
+     ctx->nodes = av_malloc((ctx->slices_width + 1) * TRELLIS_WIDTH
+                            * sizeof(*ctx->nodes));
+     if (!ctx->nodes) {
+         encode_close(avctx);
+         return AVERROR(ENOMEM);
+     }
+     for (i = min_quant; i <= max_quant; i++) {
+         ctx->nodes[i].prev_node = -1;
+         ctx->nodes[i].bits      = 0;
+         ctx->nodes[i].score     = 0;
+     }
+     ctx->slice_q = av_malloc(ctx->slices_width * sizeof(*ctx->slice_q));
+     if (!ctx->slice_q) {
+         encode_close(avctx);
+         return AVERROR(ENOMEM);
+     }
+     return 0;
+ }
+ #define OFFSET(x) offsetof(ProresContext, x)
+ #define VE     AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+ static const AVOption options[] = {
+     { "mbs_per_slice", "macroblocks per slice", OFFSET(mbs_per_slice),
+         AV_OPT_TYPE_INT, { 8 }, 1, MAX_MBS_PER_SLICE, VE },
+     { "profile",       NULL, OFFSET(profile), AV_OPT_TYPE_INT,
+         { PRORES_PROFILE_STANDARD },
+         PRORES_PROFILE_PROXY, PRORES_PROFILE_HQ, VE, "profile" },
+     { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_PROXY },
+         0, 0, VE, "profile" },
+     { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_LT },
+         0, 0, VE, "profile" },
+     { "standard",      NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_STANDARD },
+         0, 0, VE, "profile" },
+     { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_HQ },
+         0, 0, VE, "profile" },
+     { NULL }
+ };
+ static const AVClass proresenc_class = {
+     .class_name = "ProRes encoder",
+     .item_name  = av_default_item_name,
+     .option     = options,
+     .version    = LIBAVUTIL_VERSION_INT,
+ };
++AVCodec ff_prores_kostya_encoder = {
++    .name           = "prores_kostya",
+     .type           = AVMEDIA_TYPE_VIDEO,
+     .id             = CODEC_ID_PRORES,
+     .priv_data_size = sizeof(ProresContext),
+     .init           = encode_init,
+     .close          = encode_close,
+     .encode2        = encode_frame,
+     .long_name      = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"),
+     .pix_fmts       = (const enum PixelFormat[]) {
+                           PIX_FMT_YUV422P10, PIX_FMT_YUV444P10, PIX_FMT_NONE
+                       },
+     .priv_class     = &proresenc_class,
+ };
Simple merge
diff --cc libavcodec/rl.h
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1087,19 -1073,7 +1087,19 @@@ static int svq3_decode_frame(AVCodecCon
          ff_draw_horiz_band(s, 16*s->mb_y, 16);
      }
  
-     MPV_frame_end(s);
 +    left = buf_size*8 - get_bits_count(&s->gb);
 +
 +    if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) {
 +        av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left);
 +        //av_hex_dump(stderr, buf+buf_size-8, 8);
 +    }
 +
 +    if (left < 0) {
 +        av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left);
 +        return -1;
 +    }
 +
+     ff_MPV_frame_end(s);
  
      if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
          *(AVFrame *) data = *(AVFrame *) &s->current_picture;
@@@ -1123,11 -1097,8 +1123,11 @@@ static int svq3_decode_end(AVCodecConte
  
      ff_h264_free_context(h);
  
-     MPV_common_end(s);
+     ff_MPV_common_end(s);
  
 +    av_freep(&svq3->buf);
 +    svq3->buf_size = 0;
 +
      return 0;
  }
  
@@@ -821,9 -823,8 +821,9 @@@ static av_cold int decode_init(AVCodecC
      l->avctx = avctx;
      l->pic.data[0]=NULL;
      avctx->pix_fmt = PIX_FMT_BGR24;
 +    avcodec_get_frame_defaults(&l->pic);
  
-     dsputil_init(&l->dsp, avctx);
+     ff_dsputil_init(&l->dsp, avctx);
  
      l->last = av_malloc(4 * sizeof(int) * (avctx->width >> 2));
      l->clast = av_malloc(4 * sizeof(int) * (avctx->width >> 2));
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -21,8 -21,8 +21,8 @@@
  #define AVCODEC_VERSION_H
  
  #define LIBAVCODEC_VERSION_MAJOR 54
--#define LIBAVCODEC_VERSION_MINOR  2
 -#define LIBAVCODEC_VERSION_MICRO  0
++#define LIBAVCODEC_VERSION_MINOR  3
 +#define LIBAVCODEC_VERSION_MICRO 100
  
  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                 LIBAVCODEC_VERSION_MINOR, \
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1407,13 -1304,11 +1407,13 @@@ static int avi_read_seek(AVFormatContex
          /* the av_index_search_timestamp call above.                     */
          assert(stream_index == 0);
  
 +        if(avio_seek(s->pb, pos, SEEK_SET) < 0)
 +            return -1;
 +
          /* Feed the DV video stream version of the timestamp to the */
          /* DV demux so it can synthesize correct timestamps.        */
-         dv_offset_reset(avi->dv_demux, timestamp);
+         ff_dv_offset_reset(avi->dv_demux, timestamp);
  
 -        avio_seek(s->pb, pos, SEEK_SET);
          avi->stream_index= -1;
          return 0;
      }
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -33,8 -33,8 +33,8 @@@
  typedef struct DVDemuxContext DVDemuxContext;
  DVDemuxContext* avpriv_dv_init_demux(AVFormatContext* s);
  int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *);
 -int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int);
 +int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t);
- void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
+ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
  
  typedef struct DVMuxContext DVMuxContext;
  
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1473,8 -1421,8 +1473,8 @@@ static int matroska_read_header(AVForma
          } else if (!strcmp(track->codec_id, "V_QUICKTIME")
                     && (track->codec_priv.size >= 86)
                     && (track->codec_priv.data != NULL)) {
 -            track->video.fourcc = AV_RL32(track->codec_priv.data);
 -            codec_id=ff_codec_get_id(ff_codec_movvideo_tags, track->video.fourcc);
 +            fourcc = AV_RL32(track->codec_priv.data);
-             codec_id = ff_codec_get_id(codec_movvideo_tags, fourcc);
++            codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
          } else if (codec_id == CODEC_ID_PCM_S16BE) {
              switch (track->audio.bitdepth) {
              case  8:  codec_id = CODEC_ID_PCM_U8;     break;
@@@ -580,13 -580,10 +580,13 @@@ static int mkv_write_tracks(AVFormatCon
          switch (codec->codec_type) {
              case AVMEDIA_TYPE_VIDEO:
                  put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
 -                put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9);
 +                if(st->avg_frame_rate.num && st->avg_frame_rate.den && 1.0/av_q2d(st->avg_frame_rate) > av_q2d(codec->time_base))
 +                    put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9/av_q2d(st->avg_frame_rate));
 +                else
 +                    put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9);
  
                  if (!native_id &&
-                       ff_codec_get_tag(codec_movvideo_tags, codec->codec_id) &&
+                       ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) &&
                      (!ff_codec_get_tag(ff_codec_bmp_tags,   codec->codec_id)
                       || codec->codec_id == CODEC_ID_SVQ1
                       || codec->codec_id == CODEC_ID_SVQ3
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -676,22 -582,9 +676,22 @@@ static int wav_read_seek(AVFormatContex
      default:
          break;
      }
-     return pcm_read_seek(s, stream_index, timestamp, flags);
+     return ff_pcm_read_seek(s, stream_index, timestamp, flags);
  }
  
 +#define OFFSET(x) offsetof(WAVContext, x)
 +#define DEC AV_OPT_FLAG_DECODING_PARAM
 +static const AVOption demux_options[] = {
 +    { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_INT, { 0 }, 0, 1, DEC },
 +    { NULL },
 +};
 +
 +static const AVClass wav_demuxer_class = {
 +    .class_name = "WAV demuxer",
 +    .item_name  = av_default_item_name,
 +    .option     = demux_options,
 +    .version    = LIBAVUTIL_VERSION_INT,
 +};
  AVInputFormat ff_wav_demuxer = {
      .name           = "wav",
      .long_name      = NULL_IF_CONFIG_SMALL("WAV format"),