comparison dvdata.c @ 10409:3c13cad19e29 libavcodec

Split parts of dvdata.h into dvdata.c, this ensures that things like work_chunks_* and dv_idct_factor_* variables appear only once in the binary instead of 3 times. Saves 3264 bytes in .rodata and 312416 bytes in .bss on x86_64.
author reimar
date Fri, 16 Oct 2009 07:55:57 +0000
parents
children 227077518e00
comparison
equal deleted inserted replaced
10408:8fd8f6c1cdcc 10409:3c13cad19e29
1 /*
2 * Constants for DV codec
3 * Copyright (c) 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file libavcodec/dvdata.c
24 * Constants for DV codec.
25 */
26
27 #include "libavutil/rational.h"
28 #include "avcodec.h"
29 #include "dvdata.h"
30
31 static DVwork_chunk work_chunks_dv25pal [1*12*27];
32 static DVwork_chunk work_chunks_dv25pal411[1*12*27];
33 static DVwork_chunk work_chunks_dv25ntsc [1*10*27];
34 static DVwork_chunk work_chunks_dv50pal [2*12*27];
35 static DVwork_chunk work_chunks_dv50ntsc [2*10*27];
36 static DVwork_chunk work_chunks_dv100palp [2*12*27];
37 static DVwork_chunk work_chunks_dv100ntscp[2*10*27];
38 static DVwork_chunk work_chunks_dv100pali [4*12*27];
39 static DVwork_chunk work_chunks_dv100ntsci[4*10*27];
40
41 static uint32_t dv_idct_factor_sd [2*2*22*64];
42 static uint32_t dv_idct_factor_hd1080[2*4*16*64];
43 static uint32_t dv_idct_factor_hd720 [2*4*16*64];
44
45 static const DVprofile dv_profiles[] = {
46 { .dsf = 0,
47 .video_stype = 0x0,
48 .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
49 .difseg_size = 10,
50 .n_difchan = 1,
51 .time_base = { 1001, 30000 },
52 .ltc_divisor = 30,
53 .height = 480,
54 .width = 720,
55 .sar = {{10, 11}, {40, 33}},
56 .work_chunks = &work_chunks_dv25ntsc[0],
57 .idct_factor = &dv_idct_factor_sd[0],
58 .pix_fmt = PIX_FMT_YUV411P,
59 .bpm = 6,
60 .block_sizes = block_sizes_dv2550,
61 .audio_stride = 90,
62 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */
63 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
64 .audio_shuffle = dv_audio_shuffle525,
65 },
66 { .dsf = 1,
67 .video_stype = 0x0,
68 .frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */
69 .difseg_size = 12,
70 .n_difchan = 1,
71 .time_base = { 1, 25 },
72 .ltc_divisor = 25,
73 .height = 576,
74 .width = 720,
75 .sar = {{59, 54}, {118, 81}},
76 .work_chunks = &work_chunks_dv25pal[0],
77 .idct_factor = &dv_idct_factor_sd[0],
78 .pix_fmt = PIX_FMT_YUV420P,
79 .bpm = 6,
80 .block_sizes = block_sizes_dv2550,
81 .audio_stride = 108,
82 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */
83 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
84 .audio_shuffle = dv_audio_shuffle625,
85 },
86 { .dsf = 1,
87 .video_stype = 0x0,
88 .frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */
89 .difseg_size = 12,
90 .n_difchan = 1,
91 .time_base = { 1, 25 },
92 .ltc_divisor = 25,
93 .height = 576,
94 .width = 720,
95 .sar = {{59, 54}, {118, 81}},
96 .work_chunks = &work_chunks_dv25pal411[0],
97 .idct_factor = &dv_idct_factor_sd[0],
98 .pix_fmt = PIX_FMT_YUV411P,
99 .bpm = 6,
100 .block_sizes = block_sizes_dv2550,
101 .audio_stride = 108,
102 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */
103 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
104 .audio_shuffle = dv_audio_shuffle625,
105 },
106 { .dsf = 0,
107 .video_stype = 0x4,
108 .frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */
109 .difseg_size = 10, /* also known as "DVCPRO50" */
110 .n_difchan = 2,
111 .time_base = { 1001, 30000 },
112 .ltc_divisor = 30,
113 .height = 480,
114 .width = 720,
115 .sar = {{10, 11}, {40, 33}},
116 .work_chunks = &work_chunks_dv50ntsc[0],
117 .idct_factor = &dv_idct_factor_sd[0],
118 .pix_fmt = PIX_FMT_YUV422P,
119 .bpm = 6,
120 .block_sizes = block_sizes_dv2550,
121 .audio_stride = 90,
122 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */
123 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
124 .audio_shuffle = dv_audio_shuffle525,
125 },
126 { .dsf = 1,
127 .video_stype = 0x4,
128 .frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */
129 .difseg_size = 12, /* also known as "DVCPRO50" */
130 .n_difchan = 2,
131 .time_base = { 1, 25 },
132 .ltc_divisor = 25,
133 .height = 576,
134 .width = 720,
135 .sar = {{59, 54}, {118, 81}},
136 .work_chunks = &work_chunks_dv50pal[0],
137 .idct_factor = &dv_idct_factor_sd[0],
138 .pix_fmt = PIX_FMT_YUV422P,
139 .bpm = 6,
140 .block_sizes = block_sizes_dv2550,
141 .audio_stride = 108,
142 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */
143 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
144 .audio_shuffle = dv_audio_shuffle625,
145 },
146 { .dsf = 0,
147 .video_stype = 0x14,
148 .frame_size = 480000, /* SMPTE-370M - 1080i60 100 Mbps */
149 .difseg_size = 10, /* also known as "DVCPRO HD" */
150 .n_difchan = 4,
151 .time_base = { 1001, 30000 },
152 .ltc_divisor = 30,
153 .height = 1080,
154 .width = 1280,
155 .sar = {{1, 1}, {1, 1}},
156 .work_chunks = &work_chunks_dv100ntsci[0],
157 .idct_factor = &dv_idct_factor_hd1080[0],
158 .pix_fmt = PIX_FMT_YUV422P,
159 .bpm = 8,
160 .block_sizes = block_sizes_dv100,
161 .audio_stride = 90,
162 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */
163 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
164 .audio_shuffle = dv_audio_shuffle525,
165 },
166 { .dsf = 1,
167 .video_stype = 0x14,
168 .frame_size = 576000, /* SMPTE-370M - 1080i50 100 Mbps */
169 .difseg_size = 12, /* also known as "DVCPRO HD" */
170 .n_difchan = 4,
171 .time_base = { 1, 25 },
172 .ltc_divisor = 25,
173 .height = 1080,
174 .width = 1440,
175 .sar = {{1, 1}, {1, 1}},
176 .work_chunks = &work_chunks_dv100pali[0],
177 .idct_factor = &dv_idct_factor_hd1080[0],
178 .pix_fmt = PIX_FMT_YUV422P,
179 .bpm = 8,
180 .block_sizes = block_sizes_dv100,
181 .audio_stride = 108,
182 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */
183 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
184 .audio_shuffle = dv_audio_shuffle625,
185 },
186 { .dsf = 0,
187 .video_stype = 0x18,
188 .frame_size = 240000, /* SMPTE-370M - 720p60 100 Mbps */
189 .difseg_size = 10, /* also known as "DVCPRO HD" */
190 .n_difchan = 2,
191 .time_base = { 1001, 60000 },
192 .ltc_divisor = 60,
193 .height = 720,
194 .width = 960,
195 .sar = {{1, 1}, {1, 1}},
196 .work_chunks = &work_chunks_dv100ntscp[0],
197 .idct_factor = &dv_idct_factor_hd720[0],
198 .pix_fmt = PIX_FMT_YUV422P,
199 .bpm = 8,
200 .block_sizes = block_sizes_dv100,
201 .audio_stride = 90,
202 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */
203 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
204 .audio_shuffle = dv_audio_shuffle525,
205 },
206 { .dsf = 1,
207 .video_stype = 0x18,
208 .frame_size = 288000, /* SMPTE-370M - 720p50 100 Mbps */
209 .difseg_size = 12, /* also known as "DVCPRO HD" */
210 .n_difchan = 2,
211 .time_base = { 1, 50 },
212 .ltc_divisor = 50,
213 .height = 720,
214 .width = 960,
215 .sar = {{1, 1}, {1, 1}},
216 .work_chunks = &work_chunks_dv100palp[0],
217 .idct_factor = &dv_idct_factor_hd720[0],
218 .pix_fmt = PIX_FMT_YUV422P,
219 .bpm = 8,
220 .block_sizes = block_sizes_dv100,
221 .audio_stride = 90,
222 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */
223 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
224 .audio_shuffle = dv_audio_shuffle625,
225 },
226 { .dsf = 1,
227 .video_stype = 0x1,
228 .frame_size = 144000, /* IEC 61883-5 - 625/50 (PAL) */
229 .difseg_size = 12,
230 .n_difchan = 1,
231 .time_base = { 1, 25 },
232 .ltc_divisor = 25,
233 .height = 576,
234 .width = 720,
235 .sar = {{59, 54}, {118, 81}},
236 .work_chunks = &work_chunks_dv25pal[0],
237 .idct_factor = &dv_idct_factor_sd[0],
238 .pix_fmt = PIX_FMT_YUV420P,
239 .bpm = 6,
240 .block_sizes = block_sizes_dv2550,
241 .audio_stride = 108,
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,
245 }
246 };
247
248 const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
249 const uint8_t* frame, unsigned buf_size)
250 {
251 int i;
252
253 int dsf = (frame[3] & 0x80) >> 7;
254
255 int stype = frame[80*5 + 48 + 3] & 0x1f;
256
257 /* 576i50 25Mbps 4:1:1 is a special case */
258 if (dsf == 1 && stype == 0 && frame[5] & 0x07) {
259 return &dv_profiles[2];
260 }
261
262 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
263 if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
264 return &dv_profiles[i];
265
266 /* check if old sys matches and assumes corrupted input */
267 if (sys && buf_size == sys->frame_size)
268 return sys;
269
270 return NULL;
271 }
272
273 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec)
274 {
275 int i;
276
277 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
278 if (codec->height == dv_profiles[i].height &&
279 codec->pix_fmt == dv_profiles[i].pix_fmt &&
280 codec->width == dv_profiles[i].width)
281 return &dv_profiles[i];
282
283 return NULL;
284 }
285