diff mbox series

[FFmpeg-devel,RFC] avcodec/bsf: support operations on side data in AVBSFContext

Message ID 1590576634-98504-1-git-send-email-leozhang@qiyi.com
State New
Headers show
Series [FFmpeg-devel,RFC] avcodec/bsf: support operations on side data in AVBSFContext
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

leozhang May 27, 2020, 10:50 a.m. UTC
Signed-off-by: leozhang <leozhang@qiyi.com>
---
Please note that this is not a formal patch firstly. I send this to sincerely request your suggestions/objections. 

And why need operating side data in AVBSFContext? Because I'm planning to create a bitstream filter which inject AV_PKT_DATA_SPHERICAL info, and transfer to AVCodecContext/AVStream.

 libavcodec/bsf.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Andreas Rheinhardt May 27, 2020, 11:03 a.m. UTC | #1
leozhang:
> Signed-off-by: leozhang <leozhang@qiyi.com>
> ---
> Please note that this is not a formal patch firstly. I send this to sincerely request your suggestions/objections. 
> 
> And why need operating side data in AVBSFContext? Because I'm planning to create a bitstream filter which inject AV_PKT_DATA_SPHERICAL info, and transfer to AVCodecContext/AVStream.

The bsf API does not work with AVStreams. The best you could do is
attach the side data to the first packet. And to do this in a bsf, you
do not need additional fields in AVBSFContext. It can be done with an
ordinary option of the bsf you intend to create.

> 
>  libavcodec/bsf.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
> index 7ed5167..740fa78 100644
> --- a/libavcodec/bsf.h
> +++ b/libavcodec/bsf.h
> @@ -93,6 +93,12 @@ typedef struct AVBSFContext {
>       * filter in av_bsf_init().
>       */
>      AVRational time_base_out;
> +
> +    /**
> +     * Additional data associated with the entire bitstream.
> +     */
> +    AVPacketSideData *side_data;
> +    size_t         nb_side_data;>  } AVBSFContext;
>  
>  typedef struct AVBitStreamFilter {
> @@ -318,6 +324,18 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf);
>   */
>  int av_bsf_get_null_filter(AVBSFContext **bsf);
>  
> +/*
> + * functions To Be Implement
> +int av_bsf_add_side_data(AVBSFContext *bsf, enum AVPacketSideDataType type,
> +                        uint8_t *data, size_t size);
> +
> +uint8_t *av_bsf_new_side_data(AVBSFContext *bsf, 
> +                              enum AVPacketSideDataType type, size_t size);
> +
> +uint8_t *av_bsf_get_side_data(const AVBSFContext *bsf,
> +                              enum AVPacketSideDataType type, size_t *size);

Nowadays side data consists mostly of structures and not of plain
buffers, so these should return void *.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
index 7ed5167..740fa78 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf.h
@@ -93,6 +93,12 @@  typedef struct AVBSFContext {
      * filter in av_bsf_init().
      */
     AVRational time_base_out;
+
+    /**
+     * Additional data associated with the entire bitstream.
+     */
+    AVPacketSideData *side_data;
+    size_t         nb_side_data;
 } AVBSFContext;
 
 typedef struct AVBitStreamFilter {
@@ -318,6 +324,18 @@  int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf);
  */
 int av_bsf_get_null_filter(AVBSFContext **bsf);
 
+/*
+ * functions To Be Implement
+int av_bsf_add_side_data(AVBSFContext *bsf, enum AVPacketSideDataType type,
+                        uint8_t *data, size_t size);
+
+uint8_t *av_bsf_new_side_data(AVBSFContext *bsf, 
+                              enum AVPacketSideDataType type, size_t size);
+
+uint8_t *av_bsf_get_side_data(const AVBSFContext *bsf,
+                              enum AVPacketSideDataType type, size_t *size);
+ */
+
 /**
  * @}
  */