]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dvdata.h
indent
[ffmpeg] / libavcodec / dvdata.h
index 87d34c043010740be3351273eb9b6e7e5c97ce9d..7d8f19df838618744df6e75380bbd71d759d2dea 100644 (file)
@@ -2,18 +2,20 @@
  * Constants for DV codec
  * Copyright (c) 2002 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
  * Constants for DV codec.
  */
 
+#ifndef FFMPEG_DVDATA_H
+#define FFMPEG_DVDATA_H
+
+#include "libavutil/rational.h"
+#include "avcodec.h"
+
 /*
  * DVprofile is used to express the differences between various
  * DV flavors. For now it's primarily used for differentiating
@@ -47,7 +55,7 @@ typedef struct DVprofile {
                                           /* for 48Khz, 44.1Khz and 32Khz */
     int              audio_samples_dist[5];/* how many samples are supposed to be */
                                          /* in each frame in a 5 frames window */
-    const uint16_t (*audio_shuffle)[9];  /* PCM shuffling table */
+    const uint8_t  (*audio_shuffle)[9];  /* PCM shuffling table */
 } DVprofile;
 
 #define NB_DV_VLC 409
@@ -327,7 +335,7 @@ static const uint8_t dv_quant_shifts[22][4] = {
 
 static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 };
 
-/* NOTE: I prefer hardcoding the positionning of dv blocks, it is
+/* NOTE: I prefer hardcoding the positioning of dv blocks, it is
    simpler :-) */
 
 static const uint16_t dv_place_420[1620] = {
@@ -2502,7 +2510,7 @@ static const int dv_iweight_248[64] = {
  22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642,
 };
 
-static const uint16_t dv_audio_shuffle525[10][9] = {
+static const uint8_t dv_audio_shuffle525[10][9] = {
   {  0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
   {  6, 36, 66, 26, 56, 86, 16, 46, 76 },
   { 12, 42, 72,  2, 32, 62, 22, 52, 82 },
@@ -2516,7 +2524,7 @@ static const uint16_t dv_audio_shuffle525[10][9] = {
   { 25, 55, 85, 15, 45, 75,  5, 35, 65 },
 };
 
-static const uint16_t dv_audio_shuffle625[12][9] = {
+static const uint8_t dv_audio_shuffle625[12][9] = {
   {   0,  36,  72,  26,  62,  98,  16,  52,  88}, /* 1st channel */
   {   6,  42,  78,  32,  68, 104,  22,  58,  94},
   {  12,  48,  84,   2,  38,  74,  28,  64, 100},
@@ -2532,7 +2540,7 @@ static const uint16_t dv_audio_shuffle625[12][9] = {
   {  31,  67, 103,  21,  57,  93,  11,  47,  83},
 };
 
-static const __attribute__((unused)) int dv_audio_frequency[3] = {
+static const av_unused int dv_audio_frequency[3] = {
     48000, 44100, 32000,
 };
 
@@ -2653,18 +2661,18 @@ enum dv_pack_type {
 /* largest possible DV frame, in bytes (PAL 50Mbps) */
 #define DV_MAX_FRAME_SIZE 288000
 
-static inline const DVprofile* dv_frame_profile(uint8_t* frame)
+static inline const DVprofile* dv_frame_profile(const uint8_t* frame)
 {
     if ((frame[3] & 0x80) == 0) {      /* DSF flag */
         /* it's an NTSC format */
-        if ((frame[80*5 + 48 + 3] & 0x4)) { /* 4:2:2 sampling */
+        if ((frame[80*5 + 48 + 3] & 0x4) && (frame[80*5 + 48] == dv_video_source)) { /* 4:2:2 sampling */
             return &dv_profiles[3]; /* NTSC 50Mbps */
         } else { /* 4:1:1 sampling */
             return &dv_profiles[0]; /* NTSC 25Mbps */
         }
     } else {
         /* it's a PAL format */
-        if ((frame[80*5 + 48 + 3] & 0x4)) { /* 4:2:2 sampling */
+        if ((frame[80*5 + 48 + 3] & 0x4) && (frame[80*5 + 48] == dv_video_source)) { /* 4:2:2 sampling */
             return &dv_profiles[4]; /* PAL 50Mbps */
         } else if ((frame[5] & 0x07) == 0) { /* APT flag */
             return &dv_profiles[1]; /* PAL 25Mbps 4:2:0 */
@@ -2720,3 +2728,5 @@ static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf)
     buf[2] = 0xff;             /* reserved -- always 1 */
     return 3;
 }
+
+#endif /* FFMPEG_DVDATA_H */