]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dolby_e_parse.c
configure: fix vulkan dep for libglslang based filters
[ffmpeg] / libavcodec / dolby_e_parse.c
index 33ec3d7f09106e05a5a689c28546d8c68dd74229..ffedcd99a44c0e2872553deedd21d1cc89d84c74 100644 (file)
@@ -30,6 +30,10 @@ static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = {
     8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8
 };
 
+static const uint16_t sample_rate_tab[16] = {
+    0, 42965, 43008, 44800, 53706, 53760
+};
+
 static int skip_input(DBEContext *s, int nb_words)
 {
     if (nb_words > s->input_size) {
@@ -53,7 +57,7 @@ static int parse_key(DBEContext *s)
     return 0;
 }
 
-static int convert_input(DBEContext *s, int nb_words, int key)
+int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int key)
 {
     const uint8_t *src = s->input;
     uint8_t *dst = s->buffer;
@@ -63,6 +67,8 @@ static int convert_input(DBEContext *s, int nb_words, int key)
     av_assert0(nb_words <= 1024u);
 
     if (nb_words > s->input_size) {
+        if (s->avctx)
+            av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
         return AVERROR_INVALIDDATA;
     }
 
@@ -116,7 +122,7 @@ int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
 
     if ((key = parse_key(s)) < 0)
         return key;
-    if ((ret = convert_input(s, 1, key)) < 0)
+    if ((ret = ff_dolby_e_convert_input(s, 1, key)) < 0)
         return ret;
 
     skip_bits(&s->gb, 4);
@@ -127,7 +133,7 @@ int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
         return AVERROR_INVALIDDATA;
     }
 
-    if ((ret = convert_input(s, mtd_size, key)) < 0)
+    if ((ret = ff_dolby_e_convert_input(s, mtd_size, key)) < 0)
         return ret;
 
     skip_bits(&s->gb, 14);
@@ -143,7 +149,7 @@ int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
 
     header->fr_code      = get_bits(&s->gb, 4);
     header->fr_code_orig = get_bits(&s->gb, 4);
-    if (!sample_rate_tab[header->fr_code] ||
+    if (!(header->sample_rate = sample_rate_tab[header->fr_code]) ||
         !sample_rate_tab[header->fr_code_orig]) {
         if (s->avctx)
             av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");