History

dca: Move ff_dca_convert_bitstream() to the DCA common code

This makes the DCA parser and decoder independent.

Diego Biurrun committed 13 years ago

Commit 1db6a081 parent b2472536 files · +44 −75Browse files

Unified · Split

6 files
  1. libavcodec/Makefile +1 −1
  2. libavcodec/dca.c +37 −0
  3. libavcodec/dca.h +6 −0
  4. libavcodec/dca_parser.c +0 −37
  5. libavcodec/dca_parser.h +0 −36
  6. libavcodec/dcadec.c +0 −1
libavcodec/Makefile+1−1
@@ -134,7 +134,7 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o · 133 unmodified lines
134OBJS-$(CONFIG_CSCD_DECODER) += cscd.o134OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
135OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o135OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
136OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \136OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \
137 dca_parser.o synth_filter.o137 synth_filter.o
138OBJS-$(CONFIG_DFA_DECODER) += dfa.o138OBJS-$(CONFIG_DFA_DECODER) += dfa.o
139OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o139OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
140OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o140OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
libavcodec/dca.c+37−0
@@ -19,7 +19,9 @@ · 18 unmodified lines
19 */19 */
20 20
21#include <stdint.h>21#include <stdint.h>
22#include <string.h>
22 23
24#include "put_bits.h"
23#include "dca.h"25#include "dca.h"
24 26
25const uint32_t avpriv_dca_sample_rates[16] =27const uint32_t avpriv_dca_sample_rates[16] =
@@ -27,3 +29,38 @@ const uint32_t avpriv_dca_sample_rates[16] = · 1 unmodified line
27 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,29 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
28 12000, 24000, 48000, 96000, 19200030 12000, 24000, 48000, 96000, 192000
29};31};
32
33int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
34 int max_size)
35{
36 uint32_t mrk;
37 int i, tmp;
38 const uint16_t *ssrc = (const uint16_t *) src;
39 uint16_t *sdst = (uint16_t *) dst;
40 PutBitContext pb;
41
42 if ((unsigned) src_size > (unsigned) max_size)
43 src_size = max_size;
44
45 mrk = AV_RB32(src);
46 switch (mrk) {
47 case DCA_MARKER_RAW_BE:
48 memcpy(dst, src, src_size);
49 return src_size;
50 case DCA_MARKER_RAW_LE:
51 for (i = 0; i < (src_size + 1) >> 1; i++)
52 *sdst++ = av_bswap16(*ssrc++);
53 return src_size;
54 case DCA_MARKER_14B_BE:
55 case DCA_MARKER_14B_LE:
56 init_put_bits(&pb, dst, max_size);
57 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
58 tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
59 put_bits(&pb, 14, tmp);
60 }
61 flush_put_bits(&pb);
62 return (put_bits_count(&pb) + 7) >> 3;
63 default:
64 return AVERROR_INVALIDDATA;
65 }
66}
libavcodec/dca.h+6−0
@@ -39,4 +39,10 @@ · 38 unmodified lines
39 39
40extern av_export const uint32_t avpriv_dca_sample_rates[16];40extern av_export const uint32_t avpriv_dca_sample_rates[16];
41 41
42/**
43 * Convert bitstream to one representation based on sync marker
44 */
45int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
46 int max_size);
47
42#endif /* AVCODEC_DCA_H */48#endif /* AVCODEC_DCA_H */
libavcodec/dca_parser.c+0−37
@@ -24,9 +24,7 @@ · 23 unmodified lines
24 24
25#include "parser.h"25#include "parser.h"
26#include "dca.h"26#include "dca.h"
27#include "dca_parser.h"
28#include "get_bits.h"27#include "get_bits.h"
29#include "put_bits.h"
30 28
31typedef struct DCAParseContext {29typedef struct DCAParseContext {
32 ParseContext pc;30 ParseContext pc;
@@ -103,41 +101,6 @@ static av_cold int dca_parse_init(AVCodecParserContext * s) · 70 unmodified lines
103 return 0;101 return 0;
104}102}
105 103
106int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
107 int max_size)
108{
109 uint32_t mrk;
110 int i, tmp;
111 const uint16_t *ssrc = (const uint16_t *) src;
112 uint16_t *sdst = (uint16_t *) dst;
113 PutBitContext pb;
114
115 if ((unsigned) src_size > (unsigned) max_size)
116 src_size = max_size;
117
118 mrk = AV_RB32(src);
119 switch (mrk) {
120 case DCA_MARKER_RAW_BE:
121 memcpy(dst, src, src_size);
122 return src_size;
123 case DCA_MARKER_RAW_LE:
124 for (i = 0; i < (src_size + 1) >> 1; i++)
125 *sdst++ = av_bswap16(*ssrc++);
126 return src_size;
127 case DCA_MARKER_14B_BE:
128 case DCA_MARKER_14B_LE:
129 init_put_bits(&pb, dst, max_size);
130 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
131 tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
132 put_bits(&pb, 14, tmp);
133 }
134 flush_put_bits(&pb);
135 return (put_bits_count(&pb) + 7) >> 3;
136 default:
137 return AVERROR_INVALIDDATA;
138 }
139}
140
141static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,104static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
142 int *sample_rate)105 int *sample_rate)
143{106{
libavcodec/dca_parser.h+0−36
@@ -1,36 +0,0 @@
1/*
2 * DCA parser
3 * Copyright (C) 2004 Gildas Bazin
4 * Copyright (C) 2004 Benjamin Zores
5 * Copyright (C) 2006 Benjamin Larsson
6 * Copyright (C) 2007 Konstantin Shishkov
7 *
8 * This file is part of Libav.
9 *
10 * Libav is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * Libav is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with Libav; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef AVCODEC_DCA_PARSER_H
26#define AVCODEC_DCA_PARSER_H
27
28#include <stdint.h>
29
30/**
31 * Convert bitstream to one representation based on sync marker
32 */
33int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
34 int max_size);
35
36#endif /* AVCODEC_DCA_PARSER_H */
libavcodec/dcadec.c+0−1
@@ -40,7 +40,6 @@ · 39 unmodified lines
40#include "dcadata.h"40#include "dcadata.h"
41#include "dcahuff.h"41#include "dcahuff.h"
42#include "dca.h"42#include "dca.h"
43#include "dca_parser.h"
44#include "mathops.h"43#include "mathops.h"
45#include "synth_filter.h"44#include "synth_filter.h"
46#include "dcadsp.h"45#include "dcadsp.h"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t