[008/115] spdif: Convert to the new bitstream reader

Message ID 1465485217-7678-9-git-send-email-diego@biurrun.de
State Superseded
Headers show

Commit Message

Diego Biurrun June 9, 2016, 3:11 p.m.
From: Alexandra Hájková <alexandra@khirnov.net>

---
 libavformat/spdifdec.c | 7 ++++---
 libavformat/spdifenc.c | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

Comments

Anton Khirnov June 13, 2016, 6:02 p.m. | #1
Quoting Diego Biurrun (2016-06-09 17:11:50)
> From: Alexandra Hájková <alexandra@khirnov.net>
> 
> ---
>  libavformat/spdifdec.c | 7 ++++---
>  libavformat/spdifenc.c | 7 ++++---
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
> index 7c21235..fff4d65 100644
> --- a/libavformat/spdifdec.c
> +++ b/libavformat/spdifdec.c
> @@ -29,6 +29,7 @@
>  #include "spdif.h"
>  #include "libavcodec/ac3.h"
>  #include "libavcodec/aacadtsdec.h"
> +#include "libavcodec/bitstream.h"
>  
>  static int spdif_get_offset_and_codec(AVFormatContext *s,
>                                        enum IEC61937DataType data_type,
> @@ -36,7 +37,7 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
>                                        enum AVCodecID *codec)
>  {
>      AACADTSHeaderInfo aac_hdr;
> -    GetBitContext gbc;
> +    BitstreamContext bc;
>  
>      switch (data_type & 0xff) {
>      case IEC61937_AC3:
> @@ -56,8 +57,8 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
>          *codec = AV_CODEC_ID_MP3;
>          break;
>      case IEC61937_MPEG2_AAC:
> -        init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
> -        if (avpriv_aac_parse_header(&gbc, &aac_hdr)) {
> +        bitstream_init8(&bc, buf, AAC_ADTS_HEADER_SIZE);
> +        if (avpriv_aac_parse_header(&bc, &aac_hdr)) {
>              if (s) /* be silent during a probe */
>                  av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n");
>              return AVERROR_INVALIDDATA;
> diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
> index a19bcab..dc4c22b 100644
> --- a/libavformat/spdifenc.c
> +++ b/libavformat/spdifenc.c
> @@ -50,6 +50,7 @@
>  #include "avio_internal.h"
>  #include "spdif.h"
>  #include "libavcodec/ac3.h"
> +#include "libavcodec/bitstream.h"
>  #include "libavcodec/dca.h"
>  #include "libavcodec/dca_syncwords.h"
>  #include "libavcodec/aacadtsdec.h"
> @@ -350,11 +351,11 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
>  {
>      IEC61937Context *ctx = s->priv_data;
>      AACADTSHeaderInfo hdr;
> -    GetBitContext gbc;
> +    BitstreamContext bc;
>      int ret;
>  
> -    init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
> -    ret = avpriv_aac_parse_header(&gbc, &hdr);
> +    bitstream_init8(&bc, pkt->data, AAC_ADTS_HEADER_SIZE);
> +    ret = avpriv_aac_parse_header(&bc, &hdr);
>      if (ret < 0) {
>          av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");
>          return AVERROR_INVALIDDATA;
> -- 
> 2.7.3

Looks ok.

Patch

diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index 7c21235..fff4d65 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -29,6 +29,7 @@ 
 #include "spdif.h"
 #include "libavcodec/ac3.h"
 #include "libavcodec/aacadtsdec.h"
+#include "libavcodec/bitstream.h"
 
 static int spdif_get_offset_and_codec(AVFormatContext *s,
                                       enum IEC61937DataType data_type,
@@ -36,7 +37,7 @@  static int spdif_get_offset_and_codec(AVFormatContext *s,
                                       enum AVCodecID *codec)
 {
     AACADTSHeaderInfo aac_hdr;
-    GetBitContext gbc;
+    BitstreamContext bc;
 
     switch (data_type & 0xff) {
     case IEC61937_AC3:
@@ -56,8 +57,8 @@  static int spdif_get_offset_and_codec(AVFormatContext *s,
         *codec = AV_CODEC_ID_MP3;
         break;
     case IEC61937_MPEG2_AAC:
-        init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
-        if (avpriv_aac_parse_header(&gbc, &aac_hdr)) {
+        bitstream_init8(&bc, buf, AAC_ADTS_HEADER_SIZE);
+        if (avpriv_aac_parse_header(&bc, &aac_hdr)) {
             if (s) /* be silent during a probe */
                 av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n");
             return AVERROR_INVALIDDATA;
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index a19bcab..dc4c22b 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -50,6 +50,7 @@ 
 #include "avio_internal.h"
 #include "spdif.h"
 #include "libavcodec/ac3.h"
+#include "libavcodec/bitstream.h"
 #include "libavcodec/dca.h"
 #include "libavcodec/dca_syncwords.h"
 #include "libavcodec/aacadtsdec.h"
@@ -350,11 +351,11 @@  static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
 {
     IEC61937Context *ctx = s->priv_data;
     AACADTSHeaderInfo hdr;
-    GetBitContext gbc;
+    BitstreamContext bc;
     int ret;
 
-    init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
-    ret = avpriv_aac_parse_header(&gbc, &hdr);
+    bitstream_init8(&bc, pkt->data, AAC_ADTS_HEADER_SIZE);
+    ret = avpriv_aac_parse_header(&bc, &hdr);
     if (ret < 0) {
         av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");
         return AVERROR_INVALIDDATA;