@@ -1534,6 +1534,7 @@ CONFIG_EXTRA=" | |||
bswapdsp | |||
cabac | |||
dsputil | |||
dvprofile | |||
fdctdsp | |||
gcrypt | |||
golomb | |||
@@ -1749,8 +1750,8 @@ cscd_decoder_suggest="zlib" | |||
dca_decoder_select="mdct" | |||
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" | |||
eac3_decoder_select="ac3_decoder" | |||
eac3_encoder_select="ac3_encoder" | |||
@@ -2007,6 +2008,8 @@ avisynth_demuxer_deps="avisynth" | |||
avisynth_demuxer_select="riffdec" | |||
caf_demuxer_select="riffdec" | |||
dirac_demuxer_select="dirac_parser" | |||
dv_demuxer_select="dvprofile" | |||
dv_muxer_select="dvprofile" | |||
dxa_demuxer_select="riffdec" | |||
eac3_demuxer_select="ac3_parser" | |||
f4v_muxer_select="mov_muxer" | |||
@@ -13,6 +13,9 @@ libavutil: 2013-12-xx | |||
API changes, most recent first: | |||
2014-07-xx - xxxxxxx - lavc 55.56.0 - dv_profile.h | |||
Add a public API for DV profile handling. | |||
2014-06-xx - xxxxxxx - lavu 53.17.0 - imgutils.h | |||
Add av_image_check_sar(). | |||
@@ -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 | |||
@@ -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; | |||
@@ -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)) | |||
@@ -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 |
@@ -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 */ |
@@ -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 */ |
@@ -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) { | |||
@@ -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) | |||
{ | |||
@@ -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, \ | |||
@@ -39,7 +39,7 @@ | |||
#include "dv.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]; | |||
@@ -109,7 +109,7 @@ static const int dv_audio_frequency[3] = { | |||
* are converted into 16bit linear ones. | |||
*/ | |||
static int dv_extract_audio(uint8_t *frame, uint8_t **ppcm, | |||
const DVprofile *sys) | |||
const AVDVProfile *sys) | |||
{ | |||
int size, chan, i, j, d, of, smpls, freq, quant, half_ch; | |||
uint16_t lc, rc; | |||
@@ -347,7 +347,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, | |||
uint8_t *ppcm[5] = { 0 }; | |||
if (buf_size < DV_PROFILE_BYTES || | |||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || | |||
!(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) || | |||
buf_size < c->sys->frame_size) { | |||
return -1; /* Broken frame, or not enough data */ | |||
} | |||
@@ -395,7 +395,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, | |||
int64_t timestamp, int flags) | |||
{ | |||
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) | |||
const DVprofile *sys = avpriv_dv_codec_profile(c->vst->codec); | |||
const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height, | |||
c->vst->codec->pix_fmt); | |||
int64_t offset; | |||
int64_t size = avio_size(s->pb) - s->data_offset; | |||
int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size; | |||
@@ -460,9 +461,9 @@ static int dv_read_header(AVFormatContext *s) | |||
avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) | |||
return AVERROR(EIO); | |||
c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys, | |||
c->buf, | |||
DV_PROFILE_BYTES); | |||
c->dv_demux->sys = av_dv_frame_profile(c->dv_demux->sys, | |||
c->buf, | |||
DV_PROFILE_BYTES); | |||
if (!c->dv_demux->sys) { | |||
av_log(s, AV_LOG_ERROR, | |||
"Can't determine profile of DV input stream.\n"); | |||
@@ -41,7 +41,7 @@ | |||
#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 */ | |||
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 */ | |||
@@ -67,7 +67,7 @@ static const int dv_aaux_packs_dist[12][9] = { | |||
{ 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, | |||
}; | |||
static int dv_audio_frame_size(const DVprofile* sys, int frame) | |||
static int dv_audio_frame_size(const AVDVProfile* sys, int frame) | |||
{ | |||
return sys->audio_samples_dist[frame % (sizeof(sys->audio_samples_dist) / | |||
sizeof(sys->audio_samples_dist[0]))]; | |||
@@ -328,7 +328,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) | |||
c->ast[i]->codec->channels != 2)) | |||
goto bail_out; | |||
} | |||
c->sys = avpriv_dv_codec_profile(vst->codec); | |||
c->sys = av_dv_codec_profile(vst->codec->width, vst->codec->height, vst->codec->pix_fmt); | |||
if (!c->sys) | |||
goto bail_out; | |||