#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"
#include "dv_profile.h"
+#include "dv_profile_internal.h"
-static DVwork_chunk work_chunks_dv25pal [1*12*27];
-static DVwork_chunk work_chunks_dv25pal411[1*12*27];
-static DVwork_chunk work_chunks_dv25ntsc [1*10*27];
-static DVwork_chunk work_chunks_dv50pal [2*12*27];
-static DVwork_chunk work_chunks_dv50ntsc [2*10*27];
-static DVwork_chunk work_chunks_dv100palp [2*12*27];
-static DVwork_chunk work_chunks_dv100ntscp[2*10*27];
-static DVwork_chunk work_chunks_dv100pali [4*12*27];
-static DVwork_chunk work_chunks_dv100ntsci[4*10*27];
-
-static uint32_t dv_idct_factor_sd [2*2*22*64];
-static uint32_t dv_idct_factor_hd1080[2*4*16*64];
-static uint32_t dv_idct_factor_hd720 [2*4*16*64];
+#if CONFIG_DVPROFILE
static const uint8_t dv_audio_shuffle525[10][9] = {
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
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) */
.height = 480,
.width = 720,
.sar = {{8, 9}, {32, 27}},
- .work_chunks = &work_chunks_dv25ntsc[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV411P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
.height = 576,
.width = 720,
.sar = {{16, 15}, {64, 45}},
- .work_chunks = &work_chunks_dv25pal[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV420P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
.height = 576,
.width = 720,
.sar = {{16, 15}, {64, 45}},
- .work_chunks = &work_chunks_dv25pal411[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV411P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
.height = 480,
.width = 720,
.sar = {{8, 9}, {32, 27}},
- .work_chunks = &work_chunks_dv50ntsc[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
.height = 576,
.width = 720,
.sar = {{16, 15}, {64, 45}},
- .work_chunks = &work_chunks_dv50pal[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
.height = 1080,
.width = 1280,
.sar = {{1, 1}, {3, 2}},
- .work_chunks = &work_chunks_dv100ntsci[0],
- .idct_factor = &dv_idct_factor_hd1080[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 8,
.block_sizes = block_sizes_dv100,
.height = 1080,
.width = 1440,
.sar = {{1, 1}, {4, 3}},
- .work_chunks = &work_chunks_dv100pali[0],
- .idct_factor = &dv_idct_factor_hd1080[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 8,
.block_sizes = block_sizes_dv100,
.height = 720,
.width = 960,
.sar = {{1, 1}, {4, 3}},
- .work_chunks = &work_chunks_dv100ntscp[0],
- .idct_factor = &dv_idct_factor_hd720[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 8,
.block_sizes = block_sizes_dv100,
.height = 720,
.width = 960,
.sar = {{1, 1}, {4, 3}},
- .work_chunks = &work_chunks_dv100palp[0],
- .idct_factor = &dv_idct_factor_hd720[0],
.pix_fmt = AV_PIX_FMT_YUV422P,
.bpm = 8,
.block_sizes = block_sizes_dv100,
.height = 576,
.width = 720,
.sar = {{16, 15}, {64, 45}},
- .work_chunks = &work_chunks_dv25pal[0],
- .idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = AV_PIX_FMT_YUV420P,
.bpm = 6,
.block_sizes = block_sizes_dv2550,
}
};
-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* 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 < DV_PROFILE_BYTES)
/* 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];
+#endif
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)
+{
+ 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