Commit 87db7e77 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '25f613f8'

* commit '25f613f8':
  dca: Move syncword definitions to a separate header

Conflicts:
	libavcodec/dca_parser.c
	libavformat/dtsdec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 634ce8dd 25f613f8
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "libavutil/error.h" #include "libavutil/error.h"
#include "dca.h" #include "dca.h"
#include "dca_syncwords.h"
#include "put_bits.h" #include "put_bits.h"
const uint32_t avpriv_dca_sample_rates[16] = { const uint32_t avpriv_dca_sample_rates[16] = {
...@@ -49,18 +50,18 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, ...@@ -49,18 +50,18 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
mrk = AV_RB32(src); mrk = AV_RB32(src);
switch (mrk) { switch (mrk) {
case DCA_MARKER_RAW_BE: case DCA_SYNCWORD_CORE_BE:
memcpy(dst, src, src_size); memcpy(dst, src, src_size);
return src_size; return src_size;
case DCA_MARKER_RAW_LE: case DCA_SYNCWORD_CORE_LE:
for (i = 0; i < (src_size + 1) >> 1; i++) for (i = 0; i < (src_size + 1) >> 1; i++)
*sdst++ = av_bswap16(*ssrc++); *sdst++ = av_bswap16(*ssrc++);
return src_size; return src_size;
case DCA_MARKER_14B_BE: case DCA_SYNCWORD_CORE_14B_BE:
case DCA_MARKER_14B_LE: case DCA_SYNCWORD_CORE_14B_LE:
init_put_bits(&pb, dst, max_size); init_put_bits(&pb, dst, max_size);
for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) { for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; tmp = ((mrk == DCA_SYNCWORD_CORE_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
put_bits(&pb, 14, tmp); put_bits(&pb, 14, tmp);
} }
flush_put_bits(&pb); flush_put_bits(&pb);
......
...@@ -35,15 +35,6 @@ ...@@ -35,15 +35,6 @@
#include "fmtconvert.h" #include "fmtconvert.h"
#include "get_bits.h" #include "get_bits.h"
/** DCA syncwords, also used for bitstream type detection */
#define DCA_MARKER_RAW_BE 0x7FFE8001
#define DCA_MARKER_RAW_LE 0xFE7F0180
#define DCA_MARKER_14B_BE 0x1FFFE800
#define DCA_MARKER_14B_LE 0xFF1F00E8
/** DCA-HD specific block starts with this marker. */
#define DCA_HD_MARKER 0x64582025
#define DCA_PRIM_CHANNELS_MAX (7) #define DCA_PRIM_CHANNELS_MAX (7)
#define DCA_ABITS_MAX (32) /* Should be 28 */ #define DCA_ABITS_MAX (32) /* Should be 28 */
#define DCA_SUBSUBFRAMES_MAX (4) #define DCA_SUBSUBFRAMES_MAX (4)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include "dca.h" #include "dca.h"
#include "dca_syncwords.h"
#include "get_bits.h" #include "get_bits.h"
#include "parser.h" #include "parser.h"
...@@ -35,9 +36,9 @@ typedef struct DCAParseContext { ...@@ -35,9 +36,9 @@ typedef struct DCAParseContext {
} DCAParseContext; } DCAParseContext;
#define IS_MARKER(state, i, buf, buf_size) \ #define IS_MARKER(state, i, buf, buf_size) \
((state == DCA_MARKER_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \ ((state == DCA_SYNCWORD_CORE_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \
(state == DCA_MARKER_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \ (state == DCA_SYNCWORD_CORE_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \
state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE || state == DCA_HD_MARKER) state == DCA_SYNCWORD_CORE_LE || state == DCA_SYNCWORD_CORE_BE || state == DCA_SYNCWORD_SUBSTREAM)
/** /**
* Find the end of the current frame in the bitstream. * Find the end of the current frame in the bitstream.
...@@ -58,7 +59,7 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, ...@@ -58,7 +59,7 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
for (i = 0; i < buf_size; i++) { for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i]; state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) { if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) { if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
start_found = 1; start_found = 1;
pc1->lastmarker = state; pc1->lastmarker = state;
i++; i++;
...@@ -71,9 +72,9 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, ...@@ -71,9 +72,9 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
for (; i < buf_size; i++) { for (; i < buf_size; i++) {
pc1->size++; pc1->size++;
state = (state << 8) | buf[i]; state = (state << 8) | buf[i];
if (state == DCA_HD_MARKER && !pc1->hd_pos) if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos)
pc1->hd_pos = pc1->size; pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) { if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
if (pc1->framesize > pc1->size) if (pc1->framesize > pc1->size)
continue; continue;
pc->frame_start_found = 0; pc->frame_start_found = 0;
......
/*
* 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.1 of the License, or (at your option) any later version.
*
* 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_DCA_SYNCWORDS_H
#define AVCODEC_DCA_SYNCWORDS_H
enum DCASyncwords {
DCA_SYNCWORD_CORE_BE = 0x7FFE8001,
DCA_SYNCWORD_CORE_LE = 0xFE7F0180,
DCA_SYNCWORD_CORE_14B_BE = 0x1FFFE800,
DCA_SYNCWORD_CORE_14B_LE = 0xFF1F00E8,
DCA_SYNCWORD_XCH = 0x5A5A5A5A,
DCA_SYNCWORD_XXCH = 0x47004A03,
DCA_SYNCWORD_X96 = 0x1D95F262,
DCA_SYNCWORD_XBR = 0x655E315E,
DCA_SYNCWORD_LBR = 0x0A801921,
DCA_SYNCWORD_XLL = 0x41A29547,
DCA_SYNCWORD_SUBSTREAM = 0x64582025,
DCA_SYNCWORD_SUBSTREAM_CORE = 0x02B09261,
};
#endif /* AVCODEC_DCA_SYNCWORDS_H */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "avcodec.h" #include "avcodec.h"
#include "dca.h" #include "dca.h"
#include "dca_syncwords.h"
#include "dcadata.h" #include "dcadata.h"
#include "dcadsp.h" #include "dcadsp.h"
#include "dcahuff.h" #include "dcahuff.h"
...@@ -1437,7 +1438,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1437,7 +1438,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
uint32_t bits = get_bits_long(&s->gb, 32); uint32_t bits = get_bits_long(&s->gb, 32);
switch (bits) { switch (bits) {
case 0x5a5a5a5a: { case DCA_SYNCWORD_XCH: {
int ext_amode, xch_fsize; int ext_amode, xch_fsize;
s->xch_base_channel = s->prim_channels; s->xch_base_channel = s->prim_channels;
...@@ -1479,7 +1480,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1479,7 +1480,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
s->xch_present = 1; s->xch_present = 1;
break; break;
} }
case 0x47004a03: case DCA_SYNCWORD_XXCH:
/* XXCh: extended channels */ /* XXCh: extended channels */
/* usually found either in core or HD part in DTS-HD HRA streams, /* usually found either in core or HD part in DTS-HD HRA streams,
* but not in DTS-ES which contains XCh extensions instead */ * but not in DTS-ES which contains XCh extensions instead */
...@@ -1517,7 +1518,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1517,7 +1518,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
/* check for ExSS (HD part) */ /* check for ExSS (HD part) */
if (s->dca_buffer_size - s->frame_size > 32 && if (s->dca_buffer_size - s->frame_size > 32 &&
get_bits_long(&s->gb, 32) == DCA_HD_MARKER) get_bits_long(&s->gb, 32) == DCA_SYNCWORD_SUBSTREAM)
ff_dca_exss_parse_header(s); ff_dca_exss_parse_header(s);
avctx->profile = s->profile; avctx->profile = s->profile;
......
...@@ -20,16 +20,13 @@ ...@@ -20,16 +20,13 @@
*/ */
#include "libavcodec/bytestream.h" #include "libavcodec/bytestream.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/dca.h" #include "libavcodec/dca.h"
#include "libavcodec/dca_syncwords.h"
#include "libavcodec/get_bits.h"
#include "avformat.h" #include "avformat.h"
#include "rawdec.h" #include "rawdec.h"
#define DCA_MARKER_14B_BE 0x1FFFE800
#define DCA_MARKER_14B_LE 0xFF1F00E8
#define DCA_MARKER_RAW_BE 0x7FFE8001
#define DCA_MARKER_RAW_LE 0xFE7F0180
static int dts_probe(AVProbeData *p) static int dts_probe(AVProbeData *p)
{ {
const uint8_t *buf, *bufp; const uint8_t *buf, *bufp;
...@@ -53,18 +50,18 @@ static int dts_probe(AVProbeData *p) ...@@ -53,18 +50,18 @@ static int dts_probe(AVProbeData *p)
diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4)); diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
/* regular bitstream */ /* regular bitstream */
if (state == DCA_MARKER_RAW_BE) if (state == DCA_SYNCWORD_CORE_BE)
marker = 0; marker = 0;
else if (state == DCA_MARKER_RAW_LE) else if (state == DCA_SYNCWORD_CORE_LE)
marker = 1; marker = 1;
/* 14 bits big-endian bitstream */ /* 14 bits big-endian bitstream */
else if (state == DCA_MARKER_14B_BE && else if (state == DCA_SYNCWORD_CORE_14B_BE &&
(bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0) (bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
marker = 2; marker = 2;
/* 14 bits little-endian bitstream */ /* 14 bits little-endian bitstream */
else if (state == DCA_MARKER_14B_LE && else if (state == DCA_SYNCWORD_CORE_14B_LE &&
(bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007) (bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
marker = 3; marker = 3;
else else
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "spdif.h" #include "spdif.h"
#include "libavcodec/ac3.h" #include "libavcodec/ac3.h"
#include "libavcodec/dca.h" #include "libavcodec/dca.h"
#include "libavcodec/dca_syncwords.h"
#include "libavcodec/aacadtsdec.h" #include "libavcodec/aacadtsdec.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
...@@ -251,25 +252,25 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt) ...@@ -251,25 +252,25 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
switch (syncword_dts) { switch (syncword_dts) {
case DCA_MARKER_RAW_BE: case DCA_SYNCWORD_CORE_BE:
blocks = (AV_RB16(pkt->data + 4) >> 2) & 0x7f; blocks = (AV_RB16(pkt->data + 4) >> 2) & 0x7f;
core_size = ((AV_RB24(pkt->data + 5) >> 4) & 0x3fff) + 1; core_size = ((AV_RB24(pkt->data + 5) >> 4) & 0x3fff) + 1;
sample_rate = avpriv_dca_sample_rates[(pkt->data[8] >> 2) & 0x0f]; sample_rate = avpriv_dca_sample_rates[(pkt->data[8] >> 2) & 0x0f];
break; break;
case DCA_MARKER_RAW_LE: case DCA_SYNCWORD_CORE_LE:
blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f; blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f;
ctx->extra_bswap = 1; ctx->extra_bswap = 1;
break; break;
case DCA_MARKER_14B_BE: case DCA_SYNCWORD_CORE_14B_BE:
blocks = blocks =
(((pkt->data[5] & 0x07) << 4) | ((pkt->data[6] & 0x3f) >> 2)); (((pkt->data[5] & 0x07) << 4) | ((pkt->data[6] & 0x3f) >> 2));
break; break;
case DCA_MARKER_14B_LE: case DCA_SYNCWORD_CORE_14B_LE:
blocks = blocks =
(((pkt->data[4] & 0x07) << 4) | ((pkt->data[7] & 0x3f) >> 2)); (((pkt->data[4] & 0x07) << 4) | ((pkt->data[7] & 0x3f) >> 2));
ctx->extra_bswap = 1; ctx->extra_bswap = 1;
break; break;
case DCA_HD_MARKER: case DCA_SYNCWORD_SUBSTREAM:
/* We only handle HD frames that are paired with core. However, /* We only handle HD frames that are paired with core. However,
sometimes DTS-HD streams with core have a stray HD frame without sometimes DTS-HD streams with core have a stray HD frame without
core in the beginning of the stream. */ core in the beginning of the stream. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment