On 5/21/2021 3:00 PM, Anton Khirnov wrote:
This will allow to stop including avcodec.h in future commits.
---
  libavcodec/av1_parser.c |  3 ++-
  libavcodec/av1dec.c     |  5 ++---
  libavcodec/cbs.c        | 10 ++++------
  libavcodec/cbs.h        | 11 ++++-------
  4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index b6c8004ee3..29a979111e 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -73,7 +73,8 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
      if (avctx->extradata_size && !s->parsed_extradata) {
          s->parsed_extradata = 1;
- ret = ff_cbs_read_extradata_from_codec(s->cbc, td, avctx);
+        ret = ff_cbs_read_extradata_raw(s->cbc, td, avctx->extradata,
+                                        avctx->extradata_size);
          if (ret < 0) {
              av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n");
          }
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 1dda0f9160..4caa7c3a9d 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -657,9 +657,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
      av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 
0);
if (avctx->extradata && avctx->extradata_size) {
-        ret = ff_cbs_read_extradata_from_codec(s->cbc,
-                                               &s->current_obu,
-                                               avctx);
+        ret = ff_cbs_read_extradata_raw(s->cbc, &s->current_obu,
+                                        avctx->extradata, 
avctx->extradata_size);
          if (ret < 0) {
              av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
              return ret;
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index bbfafb6530..960114cb0e 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -276,13 +276,11 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
                           par->extradata_size, 1);
  }
-int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
-                                     CodedBitstreamFragment *frag,
-                                     const AVCodecContext *avctx)
+int ff_cbs_read_extradata_raw(CodedBitstreamContext *ctx,
+                              CodedBitstreamFragment *frag,
+                              const uint8_t *data, size_t size)
  {
-    return cbs_read_data(ctx, frag, NULL,
-                         avctx->extradata,
-                         avctx->extradata_size, 1);
+    return cbs_read_data(ctx, frag, NULL, data, size, 1);
  }
int ff_cbs_read_packet(CodedBitstreamContext *ctx,
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index f022282b75..8b432393b8 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -263,15 +263,12 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
                            const AVCodecParameters *par);
/**
- * Read the extradata bitstream found in a codec context into a
+ * Read the extradata bitstream provided as a raw array of bytes into a
   * fragment, then split into units and decompose.
- *
- * This acts identical to ff_cbs_read_extradata() for the case where
- * you already have a codec context.
   */
-int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
-                                     CodedBitstreamFragment *frag,
-                                     const AVCodecContext *avctx);
+int ff_cbs_read_extradata_raw(CodedBitstreamContext *ctx,
+                              CodedBitstreamFragment *frag,
+                              const uint8_t *data, size_t size);

I'd prefer if you instead declare struct AVCodecContext in cbs.h and then include avcodec.h in cbs.c, like you did in codec.h, to keep the function as is.

/**
   * Read the data bitstream from a packet into a fragment, then


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to