[010/115] adtsenc: Convert to the new bitstream reader

Message ID 1465485217-7678-11-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/adtsenc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Anton Khirnov June 13, 2016, 6:14 p.m. | #1
Quoting Diego Biurrun (2016-06-09 17:11:52)
> From: Alexandra Hájková <alexandra@khirnov.net>
> 
> ---
>  libavformat/adtsenc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
> index e7c72d8..639c39e 100644
> --- a/libavformat/adtsenc.c
> +++ b/libavformat/adtsenc.c
> @@ -20,7 +20,7 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> -#include "libavcodec/get_bits.h"
> +#include "libavcodec/bitstream.h"
>  #include "libavcodec/put_bits.h"
>  #include "libavcodec/avcodec.h"
>  #include "libavcodec/mpeg4audio.h"
> @@ -41,16 +41,16 @@ typedef struct ADTSContext {
>  
>  static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf, int size)
>  {
> -    GetBitContext gb;
> +    BitstreamContext bc;
>      PutBitContext pb;
>      MPEG4AudioConfig m4ac;
>      int off;
>  
> -    init_get_bits(&gb, buf, size * 8);
> +    bitstream_init(&bc, buf, size * 8);
>      off = avpriv_mpeg4audio_get_config(&m4ac, buf, size * 8, 1);
>      if (off < 0)
>          return off;
> -    skip_bits_long(&gb, off);
> +    bitstream_skip(&bc, off);
>      adts->objecttype        = m4ac.object_type - 1;
>      adts->sample_rate_index = m4ac.sampling_index;
>      adts->channel_conf      = m4ac.chan_config;
> @@ -63,15 +63,15 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
>          av_log(s, AV_LOG_ERROR, "Escape sample rate index illegal in ADTS\n");
>          return AVERROR_INVALIDDATA;
>      }
> -    if (get_bits(&gb, 1)) {
> +    if (bitstream_read(&bc, 1)) {
>          av_log(s, AV_LOG_ERROR, "960/120 MDCT window is not allowed in ADTS\n");
>          return AVERROR_INVALIDDATA;
>      }
> -    if (get_bits(&gb, 1)) {
> +    if (bitstream_read(&bc, 1)) {
>          av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
>          return AVERROR_INVALIDDATA;
>      }
> -    if (get_bits(&gb, 1)) {
> +    if (bitstream_read(&bc, 1)) {
>          av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n");
>          return AVERROR_INVALIDDATA;
>      }
> @@ -79,7 +79,7 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
>          init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
>  
>          put_bits(&pb, 3, 5); //ID_PCE
> -        adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8;
> +        adts->pce_size = (avpriv_copy_pce_data(&pb, &bc) + 3) / 8;
>          flush_put_bits(&pb);
>      }
>  
> -- 
> 2.7.3

Looks ok, except for the problems pointed out in the previous patch.

Patch

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index e7c72d8..639c39e 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -20,7 +20,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/get_bits.h"
+#include "libavcodec/bitstream.h"
 #include "libavcodec/put_bits.h"
 #include "libavcodec/avcodec.h"
 #include "libavcodec/mpeg4audio.h"
@@ -41,16 +41,16 @@  typedef struct ADTSContext {
 
 static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf, int size)
 {
-    GetBitContext gb;
+    BitstreamContext bc;
     PutBitContext pb;
     MPEG4AudioConfig m4ac;
     int off;
 
-    init_get_bits(&gb, buf, size * 8);
+    bitstream_init(&bc, buf, size * 8);
     off = avpriv_mpeg4audio_get_config(&m4ac, buf, size * 8, 1);
     if (off < 0)
         return off;
-    skip_bits_long(&gb, off);
+    bitstream_skip(&bc, off);
     adts->objecttype        = m4ac.object_type - 1;
     adts->sample_rate_index = m4ac.sampling_index;
     adts->channel_conf      = m4ac.chan_config;
@@ -63,15 +63,15 @@  static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
         av_log(s, AV_LOG_ERROR, "Escape sample rate index illegal in ADTS\n");
         return AVERROR_INVALIDDATA;
     }
-    if (get_bits(&gb, 1)) {
+    if (bitstream_read(&bc, 1)) {
         av_log(s, AV_LOG_ERROR, "960/120 MDCT window is not allowed in ADTS\n");
         return AVERROR_INVALIDDATA;
     }
-    if (get_bits(&gb, 1)) {
+    if (bitstream_read(&bc, 1)) {
         av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
         return AVERROR_INVALIDDATA;
     }
-    if (get_bits(&gb, 1)) {
+    if (bitstream_read(&bc, 1)) {
         av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n");
         return AVERROR_INVALIDDATA;
     }
@@ -79,7 +79,7 @@  static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
         init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
 
         put_bits(&pb, 3, 5); //ID_PCE
-        adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8;
+        adts->pce_size = (avpriv_copy_pce_data(&pb, &bc) + 3) / 8;
         flush_put_bits(&pb);
     }