Re: [FFmpeg-devel] [PATCH 2/4 v6] avformat: add a Tile Grid stream group type

2024-01-31 Thread James Almer

On 1/31/2024 3:33 PM, Andreas Rheinhardt wrote:

James Almer:

On 1/31/2024 3:08 PM, Andreas Rheinhardt wrote:

James Almer:

This will be used to support tiled image formats like HEIF.

Signed-off-by: James Almer
---
   libavformat/avformat.c |   5 +++
   libavformat/avformat.h | 100 +
   libavformat/dump.c |  29 
   libavformat/options.c  |  32 +
   4 files changed, 166 insertions(+)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 8e8c6fbe55..32ef440207 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -100,6 +100,11 @@ void ff_free_stream_group(AVStreamGroup **pstg)
  
av_iamf_mix_presentation_free(>params.iamf_mix_presentation);

   break;
   }
+    case AV_STREAM_GROUP_PARAMS_TILE_GRID:
+    av_opt_free(stg->params.tile_grid);
+    av_freep(>params.tile_grid->offsets);
+    av_freep(>params.tile_grid);
+    break;
   default:
   break;
   }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5d0fe82250..6577f13ef1 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1018,10 +1018,109 @@ typedef struct AVStream {
   int pts_wrap_bits;
   } AVStream;
   +/**
+ * AVStreamGroupTileGrid holds information on how to combine several
+ * independent images on a single grid for presentation. None of the
tiles may
+ * overlap inside the grid.
+ *
+ * The following is an example of a simple grid with 3 rows and 4
columns:
+ *
+ * +---+---+---+---+
+ * | 0 | 1 | 2 | 3 |
+ * +---+---+---+---+
+ * | 4 | 5 | 6 | 7 |
+ * +---+---+---+---+
+ * | 8 | 9 |10 |11 |
+ * +---+---+---+---+
+ *
+ * Assuming all tiles have a dimension of 512x512, the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the first @ref AVStreamGroup.streams "stream" in the group is
"0,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the second @ref AVStreamGroup.streams "stream" in the group is
"512,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the fifth @ref AVStreamGroup.streams "stream" in the group is
"0,512", the
+ * @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of
+ * the sixth @ref AVStreamGroup.streams "stream" in the group is
"512,512",
+ * etc.
+ *
+ * sizeof(AVStreamGroupTileGrid) is not a part of the ABI. No new
fields may be
+ * added to this struct without a major version bump.

This is inconsistent. I think you mean that sizeof is part of the ABI.


No? It's not a part of the ABI because AVStreamGroupTileGrid must not be
ever used on stack, or allocated by anything other than AVStreamGroup.
That way we can add fields to it without waiting for a major bump.


"No new fields may be added to this struct without a major version bump"


Ah, i see. Copy paste fail. Will remove that part.
___
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".


Re: [FFmpeg-devel] [PATCH 2/4 v6] avformat: add a Tile Grid stream group type

2024-01-31 Thread Andreas Rheinhardt
James Almer:
> On 1/31/2024 3:08 PM, Andreas Rheinhardt wrote:
>> James Almer:
>>> This will be used to support tiled image formats like HEIF.
>>>
>>> Signed-off-by: James Almer
>>> ---
>>>   libavformat/avformat.c |   5 +++
>>>   libavformat/avformat.h | 100 +
>>>   libavformat/dump.c |  29 
>>>   libavformat/options.c  |  32 +
>>>   4 files changed, 166 insertions(+)
>>>
>>> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
>>> index 8e8c6fbe55..32ef440207 100644
>>> --- a/libavformat/avformat.c
>>> +++ b/libavformat/avformat.c
>>> @@ -100,6 +100,11 @@ void ff_free_stream_group(AVStreamGroup **pstg)
>>>  
>>> av_iamf_mix_presentation_free(>params.iamf_mix_presentation);
>>>   break;
>>>   }
>>> +    case AV_STREAM_GROUP_PARAMS_TILE_GRID:
>>> +    av_opt_free(stg->params.tile_grid);
>>> +    av_freep(>params.tile_grid->offsets);
>>> +    av_freep(>params.tile_grid);
>>> +    break;
>>>   default:
>>>   break;
>>>   }
>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>> index 5d0fe82250..6577f13ef1 100644
>>> --- a/libavformat/avformat.h
>>> +++ b/libavformat/avformat.h
>>> @@ -1018,10 +1018,109 @@ typedef struct AVStream {
>>>   int pts_wrap_bits;
>>>   } AVStream;
>>>   +/**
>>> + * AVStreamGroupTileGrid holds information on how to combine several
>>> + * independent images on a single grid for presentation. None of the
>>> tiles may
>>> + * overlap inside the grid.
>>> + *
>>> + * The following is an example of a simple grid with 3 rows and 4
>>> columns:
>>> + *
>>> + * +---+---+---+---+
>>> + * | 0 | 1 | 2 | 3 |
>>> + * +---+---+---+---+
>>> + * | 4 | 5 | 6 | 7 |
>>> + * +---+---+---+---+
>>> + * | 8 | 9 |10 |11 |
>>> + * +---+---+---+---+
>>> + *
>>> + * Assuming all tiles have a dimension of 512x512, the
>>> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
>>> + * the first @ref AVStreamGroup.streams "stream" in the group is
>>> "0,0", the
>>> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
>>> + * the second @ref AVStreamGroup.streams "stream" in the group is
>>> "512,0", the
>>> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
>>> + * the fifth @ref AVStreamGroup.streams "stream" in the group is
>>> "0,512", the
>>> + * @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of
>>> + * the sixth @ref AVStreamGroup.streams "stream" in the group is
>>> "512,512",
>>> + * etc.
>>> + *
>>> + * sizeof(AVStreamGroupTileGrid) is not a part of the ABI. No new
>>> fields may be
>>> + * added to this struct without a major version bump.
>> This is inconsistent. I think you mean that sizeof is part of the ABI.
> 
> No? It's not a part of the ABI because AVStreamGroupTileGrid must not be
> ever used on stack, or allocated by anything other than AVStreamGroup.
> That way we can add fields to it without waiting for a major bump.

"No new fields may be added to this struct without a major version bump"

- Andreas

___
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".


Re: [FFmpeg-devel] [PATCH 2/4 v6] avformat: add a Tile Grid stream group type

2024-01-31 Thread James Almer

On 1/31/2024 3:08 PM, Andreas Rheinhardt wrote:

James Almer:

This will be used to support tiled image formats like HEIF.

Signed-off-by: James Almer
---
  libavformat/avformat.c |   5 +++
  libavformat/avformat.h | 100 +
  libavformat/dump.c |  29 
  libavformat/options.c  |  32 +
  4 files changed, 166 insertions(+)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 8e8c6fbe55..32ef440207 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -100,6 +100,11 @@ void ff_free_stream_group(AVStreamGroup **pstg)
  av_iamf_mix_presentation_free(>params.iamf_mix_presentation);
  break;
  }
+case AV_STREAM_GROUP_PARAMS_TILE_GRID:
+av_opt_free(stg->params.tile_grid);
+av_freep(>params.tile_grid->offsets);
+av_freep(>params.tile_grid);
+break;
  default:
  break;
  }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5d0fe82250..6577f13ef1 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1018,10 +1018,109 @@ typedef struct AVStream {
  int pts_wrap_bits;
  } AVStream;
  
+/**

+ * AVStreamGroupTileGrid holds information on how to combine several
+ * independent images on a single grid for presentation. None of the tiles may
+ * overlap inside the grid.
+ *
+ * The following is an example of a simple grid with 3 rows and 4 columns:
+ *
+ * +---+---+---+---+
+ * | 0 | 1 | 2 | 3 |
+ * +---+---+---+---+
+ * | 4 | 5 | 6 | 7 |
+ * +---+---+---+---+
+ * | 8 | 9 |10 |11 |
+ * +---+---+---+---+
+ *
+ * Assuming all tiles have a dimension of 512x512, the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the first @ref AVStreamGroup.streams "stream" in the group is "0,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the second @ref AVStreamGroup.streams "stream" in the group is "512,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the fifth @ref AVStreamGroup.streams "stream" in the group is "0,512", the
+ * @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of
+ * the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512",
+ * etc.
+ *
+ * sizeof(AVStreamGroupTileGrid) is not a part of the ABI. No new fields may be
+ * added to this struct without a major version bump.

This is inconsistent. I think you mean that sizeof is part of the ABI.


No? It's not a part of the ABI because AVStreamGroupTileGrid must not be 
ever used on stack, or allocated by anything other than AVStreamGroup.

That way we can add fields to it without waiting for a major bump.
___
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".


Re: [FFmpeg-devel] [PATCH 2/4 v6] avformat: add a Tile Grid stream group type

2024-01-31 Thread Andreas Rheinhardt
James Almer:
> This will be used to support tiled image formats like HEIF.
> 
> Signed-off-by: James Almer 
> ---
>  libavformat/avformat.c |   5 +++
>  libavformat/avformat.h | 100 +
>  libavformat/dump.c |  29 
>  libavformat/options.c  |  32 +
>  4 files changed, 166 insertions(+)
> 
> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> index 8e8c6fbe55..32ef440207 100644
> --- a/libavformat/avformat.c
> +++ b/libavformat/avformat.c
> @@ -100,6 +100,11 @@ void ff_free_stream_group(AVStreamGroup **pstg)
>  av_iamf_mix_presentation_free(>params.iamf_mix_presentation);
>  break;
>  }
> +case AV_STREAM_GROUP_PARAMS_TILE_GRID:
> +av_opt_free(stg->params.tile_grid);
> +av_freep(>params.tile_grid->offsets);
> +av_freep(>params.tile_grid);
> +break;
>  default:
>  break;
>  }
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 5d0fe82250..6577f13ef1 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1018,10 +1018,109 @@ typedef struct AVStream {
>  int pts_wrap_bits;
>  } AVStream;
>  
> +/**
> + * AVStreamGroupTileGrid holds information on how to combine several
> + * independent images on a single grid for presentation. None of the tiles 
> may
> + * overlap inside the grid.
> + *
> + * The following is an example of a simple grid with 3 rows and 4 columns:
> + *
> + * +---+---+---+---+
> + * | 0 | 1 | 2 | 3 |
> + * +---+---+---+---+
> + * | 4 | 5 | 6 | 7 |
> + * +---+---+---+---+
> + * | 8 | 9 |10 |11 |
> + * +---+---+---+---+
> + *
> + * Assuming all tiles have a dimension of 512x512, the
> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
> + * the first @ref AVStreamGroup.streams "stream" in the group is "0,0", the
> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
> + * the second @ref AVStreamGroup.streams "stream" in the group is "512,0", 
> the
> + * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
> + * the fifth @ref AVStreamGroup.streams "stream" in the group is "0,512", the
> + * @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of
> + * the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512",
> + * etc.
> + *
> + * sizeof(AVStreamGroupTileGrid) is not a part of the ABI. No new fields may 
> be
> + * added to this struct without a major version bump.

This is inconsistent. I think you mean that sizeof is part of the ABI.

> + */
> +typedef struct AVStreamGroupTileGrid {
> +const AVClass *av_class;
> +
> +/**
> + * Width of the final image in the grid.
> + *
> + * Must be > 0.
> + */
> +int coded_width;
> +/**
> + * Width of the final image in the grid.
> + *
> + * Must be > 0.
> + */
> +int coded_height;
> +
> +/**
> + * An @ref AVStreamGroup.nb_streams "nb_streams" sized array of offsets 
> in
> + * pixels from the topleft edge of the grid, indicating where each stream
> + * should be placed.
> + * It must be allocated with the av_malloc() family of functions.
> + *
> + * - demuxing: set by libavformat, must not be modified by the caller.
> + * - muxing: set by the caller before avformat_write_header().
> + *
> + * Freed by libavformat in avformat_free_context().
> + */
> +struct {
> +int x;
> +int y;
> +} *offsets;
> +
> +/**
> + * Offset in pixels from the left edge of the grid where the actual image
> + * meant for presentation starts.
> + *
> + * This field must be >= 0 and <= @ref coded_width.
> + */
> +int horizontal_offset;
> +/**
> + * Offset in pixels from the top edge of the grid where the actual image
> + * meant for presentation starts.
> + *
> + * This field must be >= 0 and <= @ref coded_height.
> + */
> +int vertical_offset;
> +
> +/**
> + * Width of the final image for presentation.
> + *
> + * Must be > 0 and <= (@ref coded_width - @ref horizontal_offset).
> + * When it's not equal to (@ref coded_width - @ref horizontal_offset), 
> the
> + * result of (@ref coded_width - width - @ref horizontal_offset) is the
> + * amount amount of pixels to be cropped from the right edge of the
> + * final image before presentation.
> + */
> +int width;
> +/**
> + * Height of the final image for presentation.
> + *
> + * Must be > 0 and <= (@ref coded_height - @ref vertical_offset).
> + * When it's not equal to (@ref coded_height - @ref vertical_offset), the
> + * result of (@ref coded_height - height - @ref vertical_offset) is the
> + * amount amount of pixels to be cropped from the bototm edge of the
> + * final image before presentation.
> + */
> +int height;
> +} AVStreamGroupTileGrid;
> +
>  enum AVStreamGroupParamsType {
>  

[FFmpeg-devel] [PATCH 2/4 v6] avformat: add a Tile Grid stream group type

2024-01-31 Thread James Almer
This will be used to support tiled image formats like HEIF.

Signed-off-by: James Almer 
---
 libavformat/avformat.c |   5 +++
 libavformat/avformat.h | 100 +
 libavformat/dump.c |  29 
 libavformat/options.c  |  32 +
 4 files changed, 166 insertions(+)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 8e8c6fbe55..32ef440207 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -100,6 +100,11 @@ void ff_free_stream_group(AVStreamGroup **pstg)
 av_iamf_mix_presentation_free(>params.iamf_mix_presentation);
 break;
 }
+case AV_STREAM_GROUP_PARAMS_TILE_GRID:
+av_opt_free(stg->params.tile_grid);
+av_freep(>params.tile_grid->offsets);
+av_freep(>params.tile_grid);
+break;
 default:
 break;
 }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5d0fe82250..6577f13ef1 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1018,10 +1018,109 @@ typedef struct AVStream {
 int pts_wrap_bits;
 } AVStream;
 
+/**
+ * AVStreamGroupTileGrid holds information on how to combine several
+ * independent images on a single grid for presentation. None of the tiles may
+ * overlap inside the grid.
+ *
+ * The following is an example of a simple grid with 3 rows and 4 columns:
+ *
+ * +---+---+---+---+
+ * | 0 | 1 | 2 | 3 |
+ * +---+---+---+---+
+ * | 4 | 5 | 6 | 7 |
+ * +---+---+---+---+
+ * | 8 | 9 |10 |11 |
+ * +---+---+---+---+
+ *
+ * Assuming all tiles have a dimension of 512x512, the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the first @ref AVStreamGroup.streams "stream" in the group is "0,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the second @ref AVStreamGroup.streams "stream" in the group is "512,0", the
+ * @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of
+ * the fifth @ref AVStreamGroup.streams "stream" in the group is "0,512", the
+ * @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of
+ * the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512",
+ * etc.
+ *
+ * sizeof(AVStreamGroupTileGrid) is not a part of the ABI. No new fields may be
+ * added to this struct without a major version bump.
+ */
+typedef struct AVStreamGroupTileGrid {
+const AVClass *av_class;
+
+/**
+ * Width of the final image in the grid.
+ *
+ * Must be > 0.
+ */
+int coded_width;
+/**
+ * Width of the final image in the grid.
+ *
+ * Must be > 0.
+ */
+int coded_height;
+
+/**
+ * An @ref AVStreamGroup.nb_streams "nb_streams" sized array of offsets in
+ * pixels from the topleft edge of the grid, indicating where each stream
+ * should be placed.
+ * It must be allocated with the av_malloc() family of functions.
+ *
+ * - demuxing: set by libavformat, must not be modified by the caller.
+ * - muxing: set by the caller before avformat_write_header().
+ *
+ * Freed by libavformat in avformat_free_context().
+ */
+struct {
+int x;
+int y;
+} *offsets;
+
+/**
+ * Offset in pixels from the left edge of the grid where the actual image
+ * meant for presentation starts.
+ *
+ * This field must be >= 0 and <= @ref coded_width.
+ */
+int horizontal_offset;
+/**
+ * Offset in pixels from the top edge of the grid where the actual image
+ * meant for presentation starts.
+ *
+ * This field must be >= 0 and <= @ref coded_height.
+ */
+int vertical_offset;
+
+/**
+ * Width of the final image for presentation.
+ *
+ * Must be > 0 and <= (@ref coded_width - @ref horizontal_offset).
+ * When it's not equal to (@ref coded_width - @ref horizontal_offset), the
+ * result of (@ref coded_width - width - @ref horizontal_offset) is the
+ * amount amount of pixels to be cropped from the right edge of the
+ * final image before presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ *
+ * Must be > 0 and <= (@ref coded_height - @ref vertical_offset).
+ * When it's not equal to (@ref coded_height - @ref vertical_offset), the
+ * result of (@ref coded_height - height - @ref vertical_offset) is the
+ * amount amount of pixels to be cropped from the bototm edge of the
+ * final image before presentation.
+ */
+int height;
+} AVStreamGroupTileGrid;
+
 enum AVStreamGroupParamsType {
 AV_STREAM_GROUP_PARAMS_NONE,
 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
+AV_STREAM_GROUP_PARAMS_TILE_GRID,
 };
 
 struct AVIAMFAudioElement;
@@ -1062,6 +1161,7 @@ typedef struct AVStreamGroup {
 union {
 struct AVIAMFAudioElement *iamf_audio_element;
 struct AVIAMFMixPresentation *iamf_mix_presentation;
+