Merge commit 'f6ee61fb05482c617f5deee29a190d8ff483b3d1'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 9 Jul 2014 20:21:46 +0000 (22:21 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 9 Jul 2014 20:27:07 +0000 (22:27 +0200)
* commit 'f6ee61fb05482c617f5deee29a190d8ff483b3d1':
  lavc: export DV profile API used by muxer/demuxer as public

Conflicts:
configure
doc/APIchanges
libavcodec/Makefile
libavcodec/dv_profile.c
libavcodec/dv_profile.h
libavcodec/version.h
libavformat/dvenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
13 files changed:
1  2 
configure
doc/APIchanges
libavcodec/Makefile
libavcodec/dv.c
libavcodec/dv.h
libavcodec/dv_profile.c
libavcodec/dv_profile.h
libavcodec/dv_profile_internal.h
libavcodec/dvdec.c
libavcodec/dvenc.c
libavcodec/version.h
libavformat/dv.c
libavformat/dvenc.c

diff --cc configure
+++ b/configure
@@@ -1801,9 -1534,8 +1801,10 @@@ CONFIG_EXTRA=
      bswapdsp
      cabac
      dsputil
+     dvprofile
 +    exif
      fdctdsp
 +    frame_thread_encoder
      gcrypt
      golomb
      gplv3
@@@ -2042,12 -1748,11 +2043,12 @@@ cook_decoder_select="audiodsp mdct sine
  cscd_decoder_select="lzo"
  cscd_decoder_suggest="zlib"
  dca_decoder_select="mdct"
 +dirac_decoder_select="dsputil dwt golomb videodsp"
  dnxhd_decoder_select="blockdsp idctdsp"
  dnxhd_encoder_select="aandcttables blockdsp dsputil fdctdsp idctdsp mpegvideoenc"
- dvvideo_decoder_select="idctdsp"
- dvvideo_encoder_select="dsputil fdctdsp"
+ dvvideo_decoder_select="dvprofile idctdsp"
+ dvvideo_encoder_select="dsputil dvprofile fdctdsp"
 -dxa_decoder_deps="zlib"
 +dxa_decoder_select="zlib"
  eac3_decoder_select="ac3_decoder"
  eac3_encoder_select="ac3_encoder"
  eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
@@@ -2353,8 -2008,8 +2354,10 @@@ avisynth_demuxer_deps="avisynth
  avisynth_demuxer_select="riffdec"
  caf_demuxer_select="riffdec"
  dirac_demuxer_select="dirac_parser"
 +dts_demuxer_select="dca_parser"
 +dtshd_demuxer_select="dca_parser"
+ dv_demuxer_select="dvprofile"
+ dv_muxer_select="dvprofile"
  dxa_demuxer_select="riffdec"
  eac3_demuxer_select="ac3_parser"
  f4v_muxer_select="mov_muxer"
diff --cc doc/APIchanges
@@@ -15,13 -13,16 +15,16 @@@ libavutil:     2012-10-2
  
  API changes, most recent first:
  
 -2014-06-xx - xxxxxxx - lavu 53.17.0 - imgutils.h
+ 2014-07-xx - xxxxxxx - lavc 55.56.0 - dv_profile.h
+   Add a public API for DV profile handling.
 +2014-06-20 - 0dceefc / 9e500ef - lavu 52.90.100 / 53.17.0 - imgutils.h
    Add av_image_check_sar().
  
 -2014-06-xx - xxxxxxx - lavc 55.55.0 - avcodec.h
 +2014-06-20 - 4a99333 / 874390e - lavc 55.68.100 / 55.55.0 - avcodec.h
    Add av_packet_rescale_ts() to simplify timestamp conversion.
  
 -2014-xx-xx - xxxxxxx - lavf 55.20.0 - avformat.h
 +2014-06-18 - ac293b6 / 194be1f - lavf 55.44.100 / 55.20.0 - avformat.h
    The proper way for providing a hint about the desired timebase to the muxers
    is now setting AVStream.time_base, instead of AVStream.codec.time_base as was
    done previously. The old method is now deprecated.
@@@ -4,8 -2,8 +4,9 @@@ NAME = avcode
  
  HEADERS = avcodec.h                                                     \
            avfft.h                                                       \
+           dv_profile.h                                                  \
            dxva2.h                                                       \
 +          old_codec_ids.h                                               \
            vaapi.h                                                       \
            vda.h                                                         \
            vdpau.h                                                       \
@@@ -19,8 -16,10 +20,9 @@@ OBJS = allcodecs.
         bitstream.o                                                      \
         bitstream_filter.o                                               \
         codec_desc.o                                                     \
+        dv_profile.o                                                     \
         fmtconvert.o                                                     \
         imgconvert.o                                                     \
 -       log2_tab.o                                                       \
         mathtables.o                                                     \
         options.o                                                        \
         parser.o                                                         \
@@@ -667,11 -559,9 +669,9 @@@ OBJS-$(CONFIG_ADTS_MUXER)              
  OBJS-$(CONFIG_ADX_DEMUXER)             += adx.o
  OBJS-$(CONFIG_CAF_DEMUXER)             += mpeg4audio.o mpegaudiodata.o  \
                                            ac3tab.o
- OBJS-$(CONFIG_DV_DEMUXER)              += dv_profile.o
- OBJS-$(CONFIG_DV_MUXER)                += dv_profile.o
 -OBJS-$(CONFIG_FLAC_DEMUXER)            += flac.o flacdata.o             \
 +OBJS-$(CONFIG_FLAC_DEMUXER)            += flac.o flacdata.o vorbis_data.o \
                                            vorbis_parser.o xiph.o
 -OBJS-$(CONFIG_FLAC_MUXER)              += flac.o flacdata.o
 +OBJS-$(CONFIG_FLAC_MUXER)              += flac.o flacdata.o vorbis_data.o
  OBJS-$(CONFIG_FLV_DEMUXER)             += mpeg4audio.o
  OBJS-$(CONFIG_GXF_DEMUXER)             += mpeg12data.o
  OBJS-$(CONFIG_IFF_DEMUXER)             += iff.o
diff --cc libavcodec/dv.c
Simple merge
diff --cc libavcodec/dv.h
Simple merge
  
  #include <stdint.h>
  
+ #include "config.h"
  #include "libavutil/common.h"
 +#include "libavutil/intreadwrite.h"
  #include "libavutil/log.h"
  #include "libavutil/pixdesc.h"
  #include "avcodec.h"
@@@ -247,12 -251,26 +252,26 @@@ static const AVDVProfile dv_profiles[] 
      }
  };
  
- const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,
-                                   const uint8_t* frame, unsigned buf_size)
+ void ff_dv_print_profiles(void *logctx, int loglevel)
+ {
+     int i;
+     for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++) {
+         const AVDVProfile *p = &dv_profiles[i];
+         av_log(logctx, loglevel, "Frame size: %dx%d; pixel format: %s, "
+                "framerate: %d/%d\n", p->width, p->height, av_get_pix_fmt_name(p->pix_fmt),
+                p->time_base.den, p->time_base.num);
+     }
+ }
+ #endif /* CONFIG_DVPROFILE */
 -const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
++const AVDVProfile* avpriv_dv_frame_profile2(AVCodecContext* codec, const AVDVProfile *sys,
+                                        const uint8_t* frame, unsigned buf_size)
  {
+ #if CONFIG_DVPROFILE
      int i, dsf, stype;
  
 -    if (buf_size < 80 * 5 + 48 + 4)
 +    if(buf_size < DV_PROFILE_BYTES)
          return NULL;
  
      dsf = (frame[3] & 0x80) >> 7;
      /* check if old sys matches and assumes corrupted input */
      if (sys && buf_size == sys->frame_size)
          return sys;
+ #endif
  
 +    /* hack for trac issue #217, dv files created with QuickTime 3 */
 +    if ((frame[3] & 0x7f) == 0x3f && frame[80 * 5 + 48 + 3] == 0xff)
 +        return &dv_profiles[dsf];
 +
      return NULL;
  }
  
- const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
-                                   const uint8_t* frame, unsigned buf_size)
++const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
++                                       const uint8_t* frame, unsigned buf_size)
 +{
 +    return avpriv_dv_frame_profile2(NULL, sys, frame, buf_size);
 +}
 +
- const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec)
+ const AVDVProfile *av_dv_codec_profile(int width, int height,
+                                        enum AVPixelFormat pix_fmt)
  {
+ #if CONFIG_DVPROFILE
      int i;
-     int w, h;
-     if (codec->coded_width || codec->coded_height) {
-         w = codec->coded_width;
-         h = codec->coded_height;
-     } else {
-         w = codec->width;
-         h = codec->height;
-     }
  
      for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
-        if (h == dv_profiles[i].height  &&
-            codec->pix_fmt == dv_profiles[i].pix_fmt &&
-            w == dv_profiles[i].width)
-                return &dv_profiles[i];
+        if (height  == dv_profiles[i].height  &&
+            pix_fmt == dv_profiles[i].pix_fmt &&
+            width   == dv_profiles[i].width)
+            return &dv_profiles[i];
+ #endif
  
      return NULL;
  }
  
- void ff_dv_print_profiles(void *logctx, int loglevel)
+ #if LIBAVCODEC_VERSION_MAJOR < 56
+ const AVDVProfile *avpriv_dv_frame_profile(const AVDVProfile *sys,
+                                          const uint8_t* frame, unsigned buf_size)
  {
-     int i;
-     for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++) {
-         const DVprofile *p = &dv_profiles[i];
-         av_log(logctx, loglevel, "Frame size: %dx%d; pixel format: %s, "
-                "framerate: %d/%d\n", p->width, p->height, av_get_pix_fmt_name(p->pix_fmt),
-                p->time_base.den, p->time_base.num);
-     }
+     return av_dv_frame_profile(sys, frame, buf_size);
+ }
+ const AVDVProfile *avpriv_dv_codec_profile(AVCodecContext *codec)
+ {
 -    return av_dv_codec_profile(codec->width, codec->height, codec->pix_fmt);
++    if (codec->coded_width || codec->coded_height) {
++        return av_dv_codec_profile(codec->coded_width, codec->coded_height, codec->pix_fmt);
++    } else
++        return av_dv_codec_profile(codec->width, codec->height, codec->pix_fmt);
  }
+ #endif
  #include "libavutil/rational.h"
  #include "avcodec.h"
  
 +/* minimum number of bytes to read from a DV stream in order to
 +   determine the profile */
 +#define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */
 +
  /*
-  * DVprofile is used to express the differences between various
+  * AVDVProfile is used to express the differences between various
   * DV flavors. For now it's primarily used for differentiating
   * 525/60 and 625/50, but the plans are to use it for various
   * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
@@@ -55,17 -51,28 +55,30 @@@ typedef struct AVDVProfile 
      int              audio_samples_dist[5]; /* how many samples are supposed to be */
                                              /* in each frame in a 5 frames window */
      const uint8_t  (*audio_shuffle)[9];     /* PCM shuffling table */
- } DVprofile;
+ } AVDVProfile;
  
- const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
-                                          const uint8_t* frame, unsigned buf_size);
- const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,
-                                   const uint8_t* frame, unsigned buf_size);
- const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec);
++const AVDVProfile* avpriv_dv_frame_profile2(AVCodecContext* codec, const AVDVProfile *sys,
++                                            const uint8_t* frame, unsigned buf_size);
+ #if LIBAVCODEC_VERSION_MAJOR < 56
+ const AVDVProfile *avpriv_dv_frame_profile(const AVDVProfile *sys,
+                                            const uint8_t* frame, unsigned buf_size);
+ const AVDVProfile *avpriv_dv_codec_profile(AVCodecContext* codec);
+ #endif
  
  /**
-  *  Print all allowed DV profiles into logctx at specified logging level.
+  * Get a DV profile for the provided compressed frame.
+  *
+  * @param sys the profile used for the previous frame, may be NULL
+  * @param frame the compressed data buffer
+  * @param buf_size size of the buffer in bytes
+  * @return the DV profile for the supplied data or NULL on failure
+  */
+ const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
+                                        const uint8_t *frame, unsigned buf_size);
+ /**
+  * Get a DV profile for the provided stream parameters.
   */
void ff_dv_print_profiles(void *logctx, int loglevel);
const AVDVProfile *av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt);
  
  #endif /* AVCODEC_DV_PROFILE_H */
index 0000000,f93e7ca..9772041
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,27 +1,27 @@@
 - * This file is part of Libav.
+ /*
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg 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.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #ifndef AVCODEC_DV_PROFILE_INTERNAL_H
+ #define AVCODEC_DV_PROFILE_INTERNAL_H
+ /**
+  *  Print all allowed DV profiles into logctx at specified logging level.
+  */
+ void ff_dv_print_profiles(void *logctx, int loglevel);
+ #endif /* AVCODEC_DV_PROFILE_INTERNAL_H */
@@@ -349,9 -341,9 +349,9 @@@ static int dvvideo_decode_frame(AVCodec
      DVVideoContext *s = avctx->priv_data;
      const uint8_t* vsc_pack;
      int apt, is16_9, ret;
-     const DVprofile *sys;
+     const AVDVProfile *sys;
  
 -    sys = avpriv_dv_frame_profile(s->sys, buf, buf_size);
 +    sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size);
      if (!sys || buf_size < sys->frame_size) {
          av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");
          return -1; /* NOTE: we only accept several full frames */
Simple merge
@@@ -29,8 -29,8 +29,8 @@@
  #include "libavutil/version.h"
  
  #define LIBAVCODEC_VERSION_MAJOR 55
- #define LIBAVCODEC_VERSION_MINOR  68
- #define LIBAVCODEC_VERSION_MICRO 102
 -#define LIBAVCODEC_VERSION_MINOR 56
 -#define LIBAVCODEC_VERSION_MICRO  0
++#define LIBAVCODEC_VERSION_MINOR  69
++#define LIBAVCODEC_VERSION_MICRO 100
  
  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                 LIBAVCODEC_VERSION_MINOR, \
  #include "libavutil/channel_layout.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/mathematics.h"
 +#include "libavutil/timecode.h"
  #include "dv.h"
 +#include "libavutil/avassert.h"
  
  struct DVDemuxContext {
-     const DVprofile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
+     const AVDVProfile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
      AVFormatContext*  fctx;
      AVStream*         vst;
      AVStream*         ast[4];
@@@ -44,8 -41,7 +44,8 @@@
  #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  
  struct DVMuxContext {
-     const DVprofile*  sys;           /* current DV profile, e.g.: 525/60, 625/50 */
 +    AVClass          *av_class;
+     const AVDVProfile*  sys;           /* current DV profile, e.g.: 525/60, 625/50 */
      int               n_ast;         /* number of stereo audio streams (up to 2) */
      AVStream         *ast[2];        /* stereo audio streams */
      AVFifoBuffer     *audio_data[2]; /* FIFO for storing excessive amounts of PCM */