2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
35static const uint8_t dv_audio_shuffle525[10][9] = {
36 { 0, 30, 60, 20, 50, 80, 10, 40, 70 },
/* 1st channel */
37 { 6, 36, 66, 26, 56, 86, 16, 46, 76 },
38 { 12, 42, 72, 2, 32, 62, 22, 52, 82 },
39 { 18, 48, 78, 8, 38, 68, 28, 58, 88 },
40 { 24, 54, 84, 14, 44, 74, 4, 34, 64 },
42 { 1, 31, 61, 21, 51, 81, 11, 41, 71 },
/* 2nd channel */
43 { 7, 37, 67, 27, 57, 87, 17, 47, 77 },
44 { 13, 43, 73, 3, 33, 63, 23, 53, 83 },
45 { 19, 49, 79, 9, 39, 69, 29, 59, 89 },
46 { 25, 55, 85, 15, 45, 75, 5, 35, 65 },
49static const uint8_t dv_audio_shuffle625[12][9] = {
50 { 0, 36, 72, 26, 62, 98, 16, 52, 88 },
/* 1st channel */
51 { 6, 42, 78, 32, 68, 104, 22, 58, 94 },
52 { 12, 48, 84, 2, 38, 74, 28, 64, 100 },
53 { 18, 54, 90, 8, 44, 80, 34, 70, 106 },
54 { 24, 60, 96, 14, 50, 86, 4, 40, 76 },
55 { 30, 66, 102, 20, 56, 92, 10, 46, 82 },
57 { 1, 37, 73, 27, 63, 99, 17, 53, 89 },
/* 2nd channel */
58 { 7, 43, 79, 33, 69, 105, 23, 59, 95 },
59 { 13, 49, 85, 3, 39, 75, 29, 65, 101 },
60 { 19, 55, 91, 9, 45, 81, 35, 71, 107 },
61 { 25, 61, 97, 15, 51, 87, 5, 41, 77 },
62 { 31, 67, 103, 21, 57, 93, 11, 47, 83 },
65/* macroblock bit budgets */
66static const uint8_t block_sizes_dv2550[8] = {
67 112, 112, 112, 112, 80, 80, 0, 0,
70static const uint8_t block_sizes_dv100[8] = {
71 80, 80, 80, 80, 80, 80, 64, 64,
77 .frame_size = 120000,
/* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
80 .time_base = { 1001, 30000 },
84 .sar = { { 8, 9 }, { 32, 27 } },
87 .block_sizes = block_sizes_dv2550,
89 .audio_min_samples = { 1580, 1452, 1053 },
/* for 48, 44.1 and 32kHz */
90 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
/* per SMPTE-314M */
91 .audio_shuffle = dv_audio_shuffle525, },
94 .frame_size = 144000,
/* IEC 61834 - 625/50 (PAL) */
97 .time_base = { 1, 25 },
101 .sar = { { 16, 15 }, { 64, 45 } },
104 .block_sizes = block_sizes_dv2550,
106 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
107 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
108 .audio_shuffle = dv_audio_shuffle625, },
111 .frame_size = 144000,
/* SMPTE-314M - 625/50 (PAL) */
114 .time_base = { 1, 25 },
118 .sar = { { 16, 15 }, { 64, 45 } },
121 .block_sizes = block_sizes_dv2550,
123 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
124 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
125 .audio_shuffle = dv_audio_shuffle625, },
128 .frame_size = 240000,
/* SMPTE-314M - 525/60 (NTSC) 50 Mbps */
129 .difseg_size = 10,
/* also known as "DVCPRO50" */
131 .time_base = { 1001, 30000 },
135 .sar = { { 8, 9 }, { 32, 27 } },
138 .block_sizes = block_sizes_dv2550,
140 .audio_min_samples = { 1580, 1452, 1053 },
/* for 48, 44.1 and 32kHz */
141 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
/* per SMPTE-314M */
142 .audio_shuffle = dv_audio_shuffle525, },
145 .frame_size = 288000,
/* SMPTE-314M - 625/50 (PAL) 50 Mbps */
146 .difseg_size = 12,
/* also known as "DVCPRO50" */
148 .time_base = { 1, 25 },
152 .sar = { { 16, 15 }, { 64, 45 } },
155 .block_sizes = block_sizes_dv2550,
157 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
158 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
159 .audio_shuffle = dv_audio_shuffle625, },
162 .frame_size = 480000,
/* SMPTE-370M - 1080i60 100 Mbps */
163 .difseg_size = 10,
/* also known as "DVCPRO HD" */
165 .time_base = { 1001, 30000 },
169 .sar = { { 1, 1 }, { 3, 2 } },
172 .block_sizes = block_sizes_dv100,
174 .audio_min_samples = { 1580, 1452, 1053 },
/* for 48, 44.1 and 32kHz */
175 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
/* per SMPTE-314M */
176 .audio_shuffle = dv_audio_shuffle525, },
179 .frame_size = 576000,
/* SMPTE-370M - 1080i50 100 Mbps */
180 .difseg_size = 12,
/* also known as "DVCPRO HD" */
182 .time_base = { 1, 25 },
186 .sar = { { 1, 1 }, { 4, 3 } },
189 .block_sizes = block_sizes_dv100,
191 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
192 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
193 .audio_shuffle = dv_audio_shuffle625, },
196 .frame_size = 240000,
/* SMPTE-370M - 720p60 100 Mbps */
197 .difseg_size = 10,
/* also known as "DVCPRO HD" */
199 .time_base = { 1001, 60000 },
203 .sar = { { 1, 1 }, { 4, 3 } },
206 .block_sizes = block_sizes_dv100,
208 .audio_min_samples = { 1580, 1452, 1053 },
/* for 48, 44.1 and 32kHz */
209 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
/* per SMPTE-314M */
210 .audio_shuffle = dv_audio_shuffle525, },
213 .frame_size = 288000,
/* SMPTE-370M - 720p50 100 Mbps */
214 .difseg_size = 12,
/* also known as "DVCPRO HD" */
216 .time_base = { 1, 50 },
220 .sar = { { 1, 1 }, { 4, 3 } },
223 .block_sizes = block_sizes_dv100,
225 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
226 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
227 .audio_shuffle = dv_audio_shuffle625, },
230 .frame_size = 144000,
/* IEC 61883-5 - 625/50 (PAL) */
233 .time_base = { 1, 25 },
237 .sar = { { 16, 15 }, { 64, 45 } },
240 .block_sizes = block_sizes_dv2550,
242 .audio_min_samples = { 1896, 1742, 1264 },
/* for 48, 44.1 and 32kHz */
243 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
244 .audio_shuffle = dv_audio_shuffle625, }
253 "Frame size: %dx%d; pixel format: %s, framerate: %d/%d\n",
255 p->time_base.den,
p->time_base.num);
259#endif /* CONFIG_DVPROFILE */
262 const uint8_t *
frame,
unsigned buf_size)
265 int i, dsf, stype, pal;
270 dsf = (
frame[3] & 0x80) >> 7;
271 stype =
frame[80 * 5 + 48 + 3] & 0x1f;
272 pal = !!(
frame[80 * 5 + 48 + 3] & 0x20);
274 /* 576i50 25Mbps 4:1:1 is a special case */
275 if ((dsf == 1 && stype == 0 &&
frame[4] & 0x07
/* the APT field */) ||
277 return &dv_profiles[2];
279 /* hack for trac issues #8333 and #2177, PAL DV files with dsf flag 0 - detect via pal flag and buf_size */
280 if (dsf == 0 && pal == 1 && stype == dv_profiles[1].video_stype && buf_size == dv_profiles[1].
frame_size)
281 return &dv_profiles[1];
284 if (dsf == dv_profiles[
i].dsf && stype == dv_profiles[
i].video_stype)
285 return &dv_profiles[
i];
287 /* check if old sys matches and assumes corrupted input */
291 /* hack for trac issue #217, dv files created with QuickTime 3 */
292 if ((
frame[3] & 0x7f) == 0x3f &&
frame[80 * 5 + 48 + 3] == 0xff)
293 return &dv_profiles[dsf];
300 const uint8_t *
frame,
unsigned buf_size)
322 /* frame rate is necessary to select between 720p50 and 720p60 profiles */
323 int invalid_framerate = frame_rate.
num == 0 || frame_rate.
den == 0;
330 if( invalid_framerate ||
av_div_q(dv_profiles[
i].time_base, frame_rate).num == 1 )
331 return &dv_profiles[
i];
Libavcodec external API header.
#define i(width, name, range_min, range_max)
static enum AVPixelFormat pix_fmt
const AVDVProfile * av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt)
Get a DV profile for the provided stream parameters.
const AVDVProfile * av_dv_codec_profile2(int width, int height, enum AVPixelFormat pix_fmt, AVRational frame_rate)
Get a DV profile for the provided stream parameters.
const AVDVProfile * av_dv_frame_profile(const AVDVProfile *sys, const uint8_t *frame, unsigned buf_size)
Get a DV profile for the provided compressed frame.
const AVDVProfile * ff_dv_frame_profile(AVCodecContext *codec, const AVDVProfile *sys, const uint8_t *frame, unsigned buf_size)
Get a DV profile for the provided compressed frame.
void ff_dv_print_profiles(void *logctx, int loglevel)
Print all allowed DV profiles into logctx at specified logging level.
static const uint8_t frame_size[4]
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Utility Preprocessor macros.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define FF_ARRAY_ELEMS(a)
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int coded_width
Bitstream width / height, may be different from width/height e.g.
Rational number (pair of numerator and denominator).