aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-04-04 13:45:45 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-04-04 13:45:45 +0000
commit6aafe463e5d1483b95ad259334c45d2741c92fb2 (patch)
tree463a55383d0006900ca7c0dbbf27465c49b11f6f /libavcodec
parentc9f97d8251e4c983aef846eb1e696de9f695c7d4 (diff)
downloadffmpeg-6aafe463e5d1483b95ad259334c45d2741c92fb2.tar.gz
support for DV aspect ratio and erroneous audio patch by (Dan Dennedy (dan at dennedy dot org) and Roman Shaposhnick <rvs at sun dot com>)
Originally committed as revision 1731 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dv.c28
-rw-r--r--libavcodec/dvdata.h4
2 files changed, 23 insertions, 9 deletions
diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 6f61242478..eb8dbb7c00 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -567,6 +567,17 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
avctx->width = width;
avctx->height = height;
+
+ /* Once again, this is pretty complicated by the fact that the same
+ * field is used differently by IEC 68134[apt == 0] and
+ * SMPTE 314M[apt == 1].
+ */
+ if (buf[VAUX_TC61_OFFSET] == 0x61 &&
+ ((apt == 0 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x07) ||
+ (apt == 1 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x02)))
+ avctx->aspect_ratio = 16.0 / 9.0;
+ else
+ avctx->aspect_ratio = 4.0 / 3.0;
s->picture.reference= 0;
if(avctx->get_buffer(avctx, &s->picture) < 0) {
@@ -674,12 +685,11 @@ static uint16_t dv_audio_12to16(uint16_t sample)
144000 bytes for PAL)
There's a couple of assumptions being made here:
- 1. We don't do any kind of audio error correction. It means,
- that erroneous samples 0x8000 are being passed upwards.
- Do we need to silence erroneous samples ? Average them ?
+ 1. By default we silence erroneous (0x8000/16bit 0x800/12bit)
+ audio samples. We can pass them upwards when ffmpeg will be ready
+ to deal with them.
2. We don't do software emphasis.
- 3. We are not checking for 'speed' argument being valid.
- 4. Audio is always returned as 16bit linear samples: 12bit
+ 3. Audio is always returned as 16bit linear samples: 12bit
nonlinear samples are converted into 16bit linear ones.
*/
static int dvaudio_decode_frame(AVCodecContext *avctx,
@@ -693,7 +703,7 @@ static int dvaudio_decode_frame(AVCodecContext *avctx,
uint8_t *buf_ptr;
/* parse id */
- init_get_bits(&s->gb, &buf[AAUX_OFFSET], 5*8);
+ init_get_bits(&s->gb, &buf[AAUX_AS_OFFSET], 5*8);
i = get_bits(&s->gb, 8);
if (i != 0x50) { /* No audio ? */
*data_size = 0;
@@ -747,6 +757,8 @@ static int dvaudio_decode_frame(AVCodecContext *avctx,
if (quant == 0) { /* 16bit quantization */
i = unshuffle[difseg][ad] + (dp - 8)/2 * stride;
((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1];
+ if (((unsigned short *)data)[i] == 0x8000)
+ ((short *)data)[i] = 0;
} else { /* 12bit quantization */
if (difseg >= nb_dif_segs/2)
goto out; /* We're not doing 4ch at this time */
@@ -755,8 +767,8 @@ static int dvaudio_decode_frame(AVCodecContext *avctx,
((uint16_t)buf_ptr[dp+2] >> 4);
rc = ((uint16_t)buf_ptr[dp+1] << 4) |
((uint16_t)buf_ptr[dp+2] & 0x0f);
- lc = dv_audio_12to16(lc);
- rc = dv_audio_12to16(rc);
+ lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
+ rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
i = unshuffle[difseg][ad] + (dp - 8)/3 * stride;
((short *)data)[i] = lc;
diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
index 29aea40224..bab69133e7 100644
--- a/libavcodec/dvdata.h
+++ b/libavcodec/dvdata.h
@@ -23,7 +23,9 @@
*/
#define NB_DV_VLC 409
-#define AAUX_OFFSET (80*6 + 80*16*3 + 3)
+#define AAUX_AS_OFFSET (80*6 + 80*16*3 + 3)
+#define AAUX_ASC_OFFSET (80*6 + 80*16*4 + 3)
+#define VAUX_TC61_OFFSET (80*5 + 48 + 5)
static const uint16_t dv_vlc_bits[409] = {
0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,