diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-07-05 09:09:15 +0000 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-07-09 13:35:07 +0000 |
commit | f6ee61fb05482c617f5deee29a190d8ff483b3d1 (patch) | |
tree | d2d6d3d48c986270164e280c06deadd724bc5b24 /libavcodec | |
parent | 3f3232a371cc88696184d9aef1f812656264e56c (diff) | |
download | ffmpeg-f6ee61fb05482c617f5deee29a190d8ff483b3d1.tar.gz |
lavc: export DV profile API used by muxer/demuxer as public
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 8 | ||||
-rw-r--r-- | libavcodec/dv.c | 4 | ||||
-rw-r--r-- | libavcodec/dv.h | 6 | ||||
-rw-r--r-- | libavcodec/dv_profile.c | 57 | ||||
-rw-r--r-- | libavcodec/dv_profile.h | 29 | ||||
-rw-r--r-- | libavcodec/dv_profile_internal.h | 27 | ||||
-rw-r--r-- | libavcodec/dvdec.c | 2 | ||||
-rw-r--r-- | libavcodec/dvenc.c | 1 | ||||
-rw-r--r-- | libavcodec/version.h | 4 |
9 files changed, 102 insertions, 36 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ab340d79e3..56aac3892f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -2,6 +2,7 @@ NAME = avcodec HEADERS = avcodec.h \ avfft.h \ + dv_profile.h \ dxva2.h \ vaapi.h \ vda.h \ @@ -15,6 +16,7 @@ OBJS = allcodecs.o \ bitstream.o \ bitstream_filter.o \ codec_desc.o \ + dv_profile.o \ fmtconvert.o \ imgconvert.o \ log2_tab.o \ @@ -164,8 +166,8 @@ OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o -OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o dv_profile.o -OBJS-$(CONFIG_DVVIDEO_ENCODER) += dvenc.o dv.o dvdata.o dv_profile.o +OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o +OBJS-$(CONFIG_DVVIDEO_ENCODER) += dvenc.o dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o OBJS-$(CONFIG_DXTORY_DECODER) += dxtory.o OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3_data.o @@ -557,8 +559,6 @@ OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o 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 \ vorbis_parser.o xiph.o OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o diff --git a/libavcodec/dv.c b/libavcodec/dv.c index bb1a26970f..e05c878ed7 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -51,7 +51,7 @@ /* XXX: also include quantization */ RL_VLC_ELEM ff_dv_rl_vlc[1184]; -static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot, +static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, int seq, int slot, uint16_t *tbl) { static const uint8_t off[] = { 2, 6, 8, 0, 4 }; @@ -175,7 +175,7 @@ static const uint8_t dv100_qstep[16] = { static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 }; -int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const DVprofile *d) +int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d) { int j,i,c,s,p; uint32_t *factor1, *factor2; diff --git a/libavcodec/dv.h b/libavcodec/dv.h index f4047a41cc..f162bb944f 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -38,7 +38,7 @@ typedef struct DVwork_chunk { } DVwork_chunk; typedef struct DVVideoContext { - const DVprofile *sys; + const AVDVProfile *sys; AVFrame *frame; AVCodecContext *avctx; uint8_t *buf; @@ -98,10 +98,10 @@ enum dv_pack_type { extern RL_VLC_ELEM ff_dv_rl_vlc[1184]; -int ff_dv_init_dynamic_tables(DVVideoContext *s, const DVprofile *d); +int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d); int ff_dvvideo_init(AVCodecContext *avctx); -static inline int dv_work_pool_size(const DVprofile *d) +static inline int dv_work_pool_size(const AVDVProfile *d) { int size = d->n_difchan*d->difseg_size*27; if (DV_PROFILE_IS_1080i50(d)) diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c index 7ceffa4a51..686632d89e 100644 --- a/libavcodec/dv_profile.c +++ b/libavcodec/dv_profile.c @@ -18,11 +18,16 @@ #include <stdint.h> +#include "config.h" + #include "libavutil/common.h" #include "libavutil/log.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "dv_profile.h" +#include "dv_profile_internal.h" + +#if CONFIG_DVPROFILE static const uint8_t dv_audio_shuffle525[10][9] = { { 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */ @@ -63,7 +68,7 @@ static const uint8_t block_sizes_dv100[8] = { 80, 80, 80, 80, 80, 80, 64, 64, }; -static const DVprofile dv_profiles[] = { +static const AVDVProfile dv_profiles[] = { { .dsf = 0, .video_stype = 0x0, .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */ @@ -246,9 +251,23 @@ static const DVprofile dv_profiles[] = { } }; -const DVprofile* avpriv_dv_frame_profile(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 uint8_t* frame, unsigned buf_size) +{ +#if CONFIG_DVPROFILE int i, dsf, stype; if (buf_size < 80 * 5 + 48 + 4) @@ -269,30 +288,36 @@ const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, /* check if old sys matches and assumes corrupted input */ if (sys && buf_size == sys->frame_size) return sys; +#endif return NULL; } -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; for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) - if (codec->height == dv_profiles[i].height && - codec->pix_fmt == dv_profiles[i].pix_fmt && - codec->width == 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); } +#endif diff --git a/libavcodec/dv_profile.h b/libavcodec/dv_profile.h index 9cf58a0bb5..f2f5ce9b9b 100644 --- a/libavcodec/dv_profile.h +++ b/libavcodec/dv_profile.h @@ -26,12 +26,12 @@ #include "avcodec.h" /* - * 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). */ -typedef struct DVprofile { +typedef struct AVDVProfile { int dsf; /* value of the dsf in the DV header */ int video_stype; /* stype for VAUX source pack */ int frame_size; /* total size of one frame in bytes */ @@ -51,15 +51,28 @@ typedef struct DVprofile { 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_codec_profile(AVCodecContext* codec); +#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 */ diff --git a/libavcodec/dv_profile_internal.h b/libavcodec/dv_profile_internal.h new file mode 100644 index 0000000000..f93e7cad17 --- /dev/null +++ b/libavcodec/dv_profile_internal.h @@ -0,0 +1,27 @@ +/* + * 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 + */ + +#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 */ diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index a03914d23e..336f32c784 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -341,7 +341,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 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); if (!sys || buf_size < sys->frame_size) { diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 7f0320087e..a4e5376bd6 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -34,6 +34,7 @@ #include "put_bits.h" #include "dv.h" #include "dv_tablegen.h" +#include "dv_profile_internal.h" static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { diff --git a/libavcodec/version.h b/libavcodec/version.h index 82601b568a..99ba6316a0 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 55 -#define LIBAVCODEC_VERSION_MINOR 55 -#define LIBAVCODEC_VERSION_MICRO 2 +#define LIBAVCODEC_VERSION_MINOR 56 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ |