• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/dvdata.c

Go to the documentation of this file.
00001 /*
00002  * Constants for DV codec
00003  * Copyright (c) 2002 Fabrice Bellard
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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,        /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
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 = {{10, 11}, {40, 33}},
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 }, /* for 48, 44.1 and 32kHz */
00063       .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
00064       .audio_shuffle = dv_audio_shuffle525,
00065     },
00066     { .dsf = 1,
00067       .video_stype = 0x0,
00068       .frame_size = 144000,        /* IEC 61834 - 625/50 (PAL) */
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 = {{59, 54}, {118, 81}},
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 }, /* for 48, 44.1 and 32kHz */
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,        /* SMPTE-314M - 625/50 (PAL) */
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 = {{59, 54}, {118, 81}},
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 }, /* for 48, 44.1 and 32kHz */
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,        /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */
00109       .difseg_size = 10,           /* also known as "DVCPRO50" */
00110       .n_difchan = 2,
00111       .time_base = { 1001, 30000 },
00112       .ltc_divisor = 30,
00113       .height = 480,
00114       .width = 720,
00115       .sar = {{10, 11}, {40, 33}},
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 }, /* for 48, 44.1 and 32kHz */
00123       .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
00124       .audio_shuffle = dv_audio_shuffle525,
00125     },
00126     { .dsf = 1,
00127       .video_stype = 0x4,
00128       .frame_size = 288000,        /* SMPTE-314M - 625/50 (PAL) 50 Mbps */
00129       .difseg_size = 12,           /* also known as "DVCPRO50" */
00130       .n_difchan = 2,
00131       .time_base = { 1, 25 },
00132       .ltc_divisor = 25,
00133       .height = 576,
00134       .width = 720,
00135       .sar = {{59, 54}, {118, 81}},
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 }, /* for 48, 44.1 and 32kHz */
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,        /* SMPTE-370M - 1080i60 100 Mbps */
00149       .difseg_size = 10,           /* also known as "DVCPRO HD" */
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 }, /* for 48, 44.1 and 32kHz */
00163       .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
00164       .audio_shuffle = dv_audio_shuffle525,
00165     },
00166     { .dsf = 1,
00167       .video_stype = 0x14,
00168       .frame_size = 576000,        /* SMPTE-370M - 1080i50 100 Mbps */
00169       .difseg_size = 12,           /* also known as "DVCPRO HD" */
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 }, /* for 48, 44.1 and 32kHz */
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,        /* SMPTE-370M - 720p60 100 Mbps */
00189       .difseg_size = 10,           /* also known as "DVCPRO HD" */
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 }, /* for 48, 44.1 and 32kHz */
00203       .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */
00204       .audio_shuffle = dv_audio_shuffle525,
00205     },
00206     { .dsf = 1,
00207       .video_stype = 0x18,
00208       .frame_size = 288000,        /* SMPTE-370M - 720p50 100 Mbps */
00209       .difseg_size = 12,           /* also known as "DVCPRO HD" */
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 }, /* for 48, 44.1 and 32kHz */
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,        /* IEC 61883-5 - 625/50 (PAL) */
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 = {{59, 54}, {118, 81}},
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 }, /* for 48, 44.1 and 32kHz */
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;
00252 
00253    int dsf = (frame[3] & 0x80) >> 7;
00254 
00255    int stype = frame[80*5 + 48 + 3] & 0x1f;
00256 
00257    /* 576i50 25Mbps 4:1:1 is a special case */
00258    if (dsf == 1 && stype == 0 && frame[5] & 0x07) {
00259        return &dv_profiles[2];
00260    }
00261 
00262    for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
00263        if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
00264            return &dv_profiles[i];
00265 
00266    /* check if old sys matches and assumes corrupted input */
00267    if (sys && buf_size == sys->frame_size)
00268        return sys;
00269 
00270    return NULL;
00271 }
00272 
00273 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec)
00274 {
00275     int i;
00276 
00277     for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
00278        if (codec->height  == dv_profiles[i].height  &&
00279            codec->pix_fmt == dv_profiles[i].pix_fmt &&
00280            codec->width   == dv_profiles[i].width)
00281                return &dv_profiles[i];
00282 
00283     return NULL;
00284 }
00285 

Generated on Fri Sep 16 2011 17:17:35 for FFmpeg by  doxygen 1.7.1