00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include "libavutil/rational.h"
00028 #include "avcodec.h"
00029 #include "dvdata.h"
00030
00031 static DVwork_chunk work_chunks_dv25pal [1*12*27];
00032 static DVwork_chunk work_chunks_dv25pal411[1*12*27];
00033 static DVwork_chunk work_chunks_dv25ntsc [1*10*27];
00034 static DVwork_chunk work_chunks_dv50pal [2*12*27];
00035 static DVwork_chunk work_chunks_dv50ntsc [2*10*27];
00036 static DVwork_chunk work_chunks_dv100palp [2*12*27];
00037 static DVwork_chunk work_chunks_dv100ntscp[2*10*27];
00038 static DVwork_chunk work_chunks_dv100pali [4*12*27];
00039 static DVwork_chunk work_chunks_dv100ntsci[4*10*27];
00040
00041 static uint32_t dv_idct_factor_sd [2*2*22*64];
00042 static uint32_t dv_idct_factor_hd1080[2*4*16*64];
00043 static uint32_t dv_idct_factor_hd720 [2*4*16*64];
00044
00045 static const DVprofile dv_profiles[] = {
00046 { .dsf = 0,
00047 .video_stype = 0x0,
00048 .frame_size = 120000,
00049 .difseg_size = 10,
00050 .n_difchan = 1,
00051 .time_base = { 1001, 30000 },
00052 .ltc_divisor = 30,
00053 .height = 480,
00054 .width = 720,
00055 .sar = {{8, 9}, {32, 27}},
00056 .work_chunks = &work_chunks_dv25ntsc[0],
00057 .idct_factor = &dv_idct_factor_sd[0],
00058 .pix_fmt = PIX_FMT_YUV411P,
00059 .bpm = 6,
00060 .block_sizes = block_sizes_dv2550,
00061 .audio_stride = 90,
00062 .audio_min_samples = { 1580, 1452, 1053 },
00063 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
00064 .audio_shuffle = dv_audio_shuffle525,
00065 },
00066 { .dsf = 1,
00067 .video_stype = 0x0,
00068 .frame_size = 144000,
00069 .difseg_size = 12,
00070 .n_difchan = 1,
00071 .time_base = { 1, 25 },
00072 .ltc_divisor = 25,
00073 .height = 576,
00074 .width = 720,
00075 .sar = {{16, 15}, {64, 45}},
00076 .work_chunks = &work_chunks_dv25pal[0],
00077 .idct_factor = &dv_idct_factor_sd[0],
00078 .pix_fmt = PIX_FMT_YUV420P,
00079 .bpm = 6,
00080 .block_sizes = block_sizes_dv2550,
00081 .audio_stride = 108,
00082 .audio_min_samples = { 1896, 1742, 1264 },
00083 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00084 .audio_shuffle = dv_audio_shuffle625,
00085 },
00086 { .dsf = 1,
00087 .video_stype = 0x0,
00088 .frame_size = 144000,
00089 .difseg_size = 12,
00090 .n_difchan = 1,
00091 .time_base = { 1, 25 },
00092 .ltc_divisor = 25,
00093 .height = 576,
00094 .width = 720,
00095 .sar = {{16, 15}, {64, 45}},
00096 .work_chunks = &work_chunks_dv25pal411[0],
00097 .idct_factor = &dv_idct_factor_sd[0],
00098 .pix_fmt = PIX_FMT_YUV411P,
00099 .bpm = 6,
00100 .block_sizes = block_sizes_dv2550,
00101 .audio_stride = 108,
00102 .audio_min_samples = { 1896, 1742, 1264 },
00103 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00104 .audio_shuffle = dv_audio_shuffle625,
00105 },
00106 { .dsf = 0,
00107 .video_stype = 0x4,
00108 .frame_size = 240000,
00109 .difseg_size = 10,
00110 .n_difchan = 2,
00111 .time_base = { 1001, 30000 },
00112 .ltc_divisor = 30,
00113 .height = 480,
00114 .width = 720,
00115 .sar = {{8, 9}, {32, 27}},
00116 .work_chunks = &work_chunks_dv50ntsc[0],
00117 .idct_factor = &dv_idct_factor_sd[0],
00118 .pix_fmt = PIX_FMT_YUV422P,
00119 .bpm = 6,
00120 .block_sizes = block_sizes_dv2550,
00121 .audio_stride = 90,
00122 .audio_min_samples = { 1580, 1452, 1053 },
00123 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
00124 .audio_shuffle = dv_audio_shuffle525,
00125 },
00126 { .dsf = 1,
00127 .video_stype = 0x4,
00128 .frame_size = 288000,
00129 .difseg_size = 12,
00130 .n_difchan = 2,
00131 .time_base = { 1, 25 },
00132 .ltc_divisor = 25,
00133 .height = 576,
00134 .width = 720,
00135 .sar = {{16, 15}, {64, 45}},
00136 .work_chunks = &work_chunks_dv50pal[0],
00137 .idct_factor = &dv_idct_factor_sd[0],
00138 .pix_fmt = PIX_FMT_YUV422P,
00139 .bpm = 6,
00140 .block_sizes = block_sizes_dv2550,
00141 .audio_stride = 108,
00142 .audio_min_samples = { 1896, 1742, 1264 },
00143 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00144 .audio_shuffle = dv_audio_shuffle625,
00145 },
00146 { .dsf = 0,
00147 .video_stype = 0x14,
00148 .frame_size = 480000,
00149 .difseg_size = 10,
00150 .n_difchan = 4,
00151 .time_base = { 1001, 30000 },
00152 .ltc_divisor = 30,
00153 .height = 1080,
00154 .width = 1280,
00155 .sar = {{1, 1}, {3, 2}},
00156 .work_chunks = &work_chunks_dv100ntsci[0],
00157 .idct_factor = &dv_idct_factor_hd1080[0],
00158 .pix_fmt = PIX_FMT_YUV422P,
00159 .bpm = 8,
00160 .block_sizes = block_sizes_dv100,
00161 .audio_stride = 90,
00162 .audio_min_samples = { 1580, 1452, 1053 },
00163 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
00164 .audio_shuffle = dv_audio_shuffle525,
00165 },
00166 { .dsf = 1,
00167 .video_stype = 0x14,
00168 .frame_size = 576000,
00169 .difseg_size = 12,
00170 .n_difchan = 4,
00171 .time_base = { 1, 25 },
00172 .ltc_divisor = 25,
00173 .height = 1080,
00174 .width = 1440,
00175 .sar = {{1, 1}, {4, 3}},
00176 .work_chunks = &work_chunks_dv100pali[0],
00177 .idct_factor = &dv_idct_factor_hd1080[0],
00178 .pix_fmt = PIX_FMT_YUV422P,
00179 .bpm = 8,
00180 .block_sizes = block_sizes_dv100,
00181 .audio_stride = 108,
00182 .audio_min_samples = { 1896, 1742, 1264 },
00183 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00184 .audio_shuffle = dv_audio_shuffle625,
00185 },
00186 { .dsf = 0,
00187 .video_stype = 0x18,
00188 .frame_size = 240000,
00189 .difseg_size = 10,
00190 .n_difchan = 2,
00191 .time_base = { 1001, 60000 },
00192 .ltc_divisor = 60,
00193 .height = 720,
00194 .width = 960,
00195 .sar = {{1, 1}, {4, 3}},
00196 .work_chunks = &work_chunks_dv100ntscp[0],
00197 .idct_factor = &dv_idct_factor_hd720[0],
00198 .pix_fmt = PIX_FMT_YUV422P,
00199 .bpm = 8,
00200 .block_sizes = block_sizes_dv100,
00201 .audio_stride = 90,
00202 .audio_min_samples = { 1580, 1452, 1053 },
00203 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 },
00204 .audio_shuffle = dv_audio_shuffle525,
00205 },
00206 { .dsf = 1,
00207 .video_stype = 0x18,
00208 .frame_size = 288000,
00209 .difseg_size = 12,
00210 .n_difchan = 2,
00211 .time_base = { 1, 50 },
00212 .ltc_divisor = 50,
00213 .height = 720,
00214 .width = 960,
00215 .sar = {{1, 1}, {4, 3}},
00216 .work_chunks = &work_chunks_dv100palp[0],
00217 .idct_factor = &dv_idct_factor_hd720[0],
00218 .pix_fmt = PIX_FMT_YUV422P,
00219 .bpm = 8,
00220 .block_sizes = block_sizes_dv100,
00221 .audio_stride = 90,
00222 .audio_min_samples = { 1896, 1742, 1264 },
00223 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00224 .audio_shuffle = dv_audio_shuffle625,
00225 },
00226 { .dsf = 1,
00227 .video_stype = 0x1,
00228 .frame_size = 144000,
00229 .difseg_size = 12,
00230 .n_difchan = 1,
00231 .time_base = { 1, 25 },
00232 .ltc_divisor = 25,
00233 .height = 576,
00234 .width = 720,
00235 .sar = {{16, 15}, {64, 45}},
00236 .work_chunks = &work_chunks_dv25pal[0],
00237 .idct_factor = &dv_idct_factor_sd[0],
00238 .pix_fmt = PIX_FMT_YUV420P,
00239 .bpm = 6,
00240 .block_sizes = block_sizes_dv2550,
00241 .audio_stride = 108,
00242 .audio_min_samples = { 1896, 1742, 1264 },
00243 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
00244 .audio_shuffle = dv_audio_shuffle625,
00245 }
00246 };
00247
00248 const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
00249 const uint8_t* frame, unsigned buf_size)
00250 {
00251 int i, dsf, stype;
00252
00253 if(buf_size < DV_PROFILE_BYTES)
00254 return NULL;
00255
00256 dsf = (frame[3] & 0x80) >> 7;
00257 stype = frame[80*5 + 48 + 3] & 0x1f;
00258
00259
00260 if (dsf == 1 && stype == 0 && frame[4] & 0x07 ) {
00261 return &dv_profiles[2];
00262 }
00263
00264 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
00265 if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
00266 return &dv_profiles[i];
00267
00268
00269 if (sys && buf_size == sys->frame_size)
00270 return sys;
00271
00272 return NULL;
00273 }
00274
00275 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec)
00276 {
00277 int i;
00278
00279 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
00280 if (codec->height == dv_profiles[i].height &&
00281 codec->pix_fmt == dv_profiles[i].pix_fmt &&
00282 codec->width == dv_profiles[i].width)
00283 return &dv_profiles[i];
00284
00285 return NULL;
00286 }
00287