summaryrefslogtreecommitdiff
path: root/libavcodec/dolby_e.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-26 16:33:01 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-30 05:14:45 +0100
commit7c27513d0458c7e80925e27529acee4473baedf6 (patch)
tree773cf01219127a0a6524da6ade66d58eb6a5d16c /libavcodec/dolby_e.c
parent8cbff41583409210abef0f57a1afbf8bb1f1f351 (diff)
downloadffmpeg-7c27513d0458c7e80925e27529acee4473baedf6.tar.gz
avcodec/dolby_e: Avoid code duplication when converting input
convert_input, a nontrivial auxiliary function used by both the general parsing code as well as the decoder itself, has been duplicated in c7016e35a624a75bb5b82bee932ddfe28d013b3f; this commit removes said duplication. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/dolby_e.c')
-rw-r--r--libavcodec/dolby_e.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index f828de2f88..9031c18210 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -25,7 +25,6 @@
#include "internal.h"
#include "get_bits.h"
-#include "put_bits.h"
#include "dolby_e.h"
#include "kbdwin.h"
#include "fft.h"
@@ -626,42 +625,6 @@ static int parse_key(DBEContext *s)
return 0;
}
-static int convert_input(DBEContext *s, int nb_words, int key)
-{
- const uint8_t *src = s->input;
- uint8_t *dst = s->buffer;
- PutBitContext pb;
- int i;
-
- av_assert0(nb_words <= 1024u);
-
- if (nb_words > s->input_size) {
- av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
- return AVERROR_INVALIDDATA;
- }
-
- switch (s->word_bits) {
- case 16:
- for (i = 0; i < nb_words; i++, src += 2, dst += 2)
- AV_WB16(dst, AV_RB16(src) ^ key);
- break;
- case 20:
- init_put_bits(&pb, s->buffer, sizeof(s->buffer));
- for (i = 0; i < nb_words; i++, src += 3)
- put_bits(&pb, 20, AV_RB24(src) >> 4 ^ key);
- flush_put_bits(&pb);
- break;
- case 24:
- for (i = 0; i < nb_words; i++, src += 3, dst += 3)
- AV_WB24(dst, AV_RB24(src) ^ key);
- break;
- default:
- av_assert0(0);
- }
-
- return init_get_bits(&s->gb, s->buffer, nb_words * s->word_bits);
-}
-
static int parse_metadata_ext(DBEDecodeContext *s1)
{
DBEContext *s = &s1->dectx;
@@ -992,7 +955,8 @@ static int parse_audio(DBEDecodeContext *s1, int start, int end, int seg_id)
s1->channels[seg_id][ch].nb_groups = 0;
continue;
}
- if ((ret = convert_input(s, s->metadata.ch_size[ch], key)) < 0)
+ ret = ff_dolby_e_convert_input(s, s->metadata.ch_size[ch], key);
+ if (ret < 0)
return ret;
if ((ret = parse_channel(s1, ch, seg_id)) < 0) {
if (s1->avctx->err_recognition & AV_EF_EXPLODE)