Commit 41e349c2 authored by James Almer's avatar James Almer

avformat/mov: add support for tile HEIF still images

Export each tile as its own stream, and the grid information as a Stream Group
of type TILE_GRID.
This also enables exporting other stream items like thumbnails, which may be
present in non tiled HEIF images too. For those, the primary stream will be
tagged with the default disposition.

Based on a patch by Swaraj Hota
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 25a10677
......@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
2024-02-26 - xxxxxxxxxx - lavf 60.22.101 - avformat.h
AV_DISPOSITION_DEPENDENT may now also be used for video streams
intended to be merged with other video streams for presentation.
2024-02-26 - xxxxxxxxxx - lavf 60.22.100 - avformat.h
Add AVStreamGroupTileGrid
Add AV_STREAM_GROUP_PARAMS_TILE_GRID
......
......@@ -119,6 +119,14 @@ void ff_remove_stream(AVFormatContext *s, AVStream *st)
ff_free_stream(&s->streams[ --s->nb_streams ]);
}
void ff_remove_stream_group(AVFormatContext *s, AVStreamGroup *stg)
{
av_assert0(s->nb_stream_groups > 0);
av_assert0(s->stream_groups[ s->nb_stream_groups - 1 ] == stg);
ff_free_stream_group(&s->stream_groups[ --s->nb_stream_groups ]);
}
/* XXX: suppress the packet queue */
void ff_flush_packet_queue(AVFormatContext *s)
{
......
......@@ -802,9 +802,9 @@ typedef struct AVIndexEntry {
*/
#define AV_DISPOSITION_METADATA (1 << 18)
/**
* The audio stream is intended to be mixed with another stream before
* presentation.
* Corresponds to mix_type=0 in mpegts.
* The stream is intended to be mixed with another stream before presentation.
* Used for example to signal the stream contains an image part of a HEIF grid,
* or for mix_type=0 in mpegts.
*/
#define AV_DISPOSITION_DEPENDENT (1 << 19)
/**
......
......@@ -637,6 +637,11 @@ void ff_remove_stream(AVFormatContext *s, AVStream *st);
* is not yet attached to an AVFormatContext.
*/
void ff_free_stream_group(AVStreamGroup **pstg);
/**
* Remove a stream group from its AVFormatContext and free it.
* The stream group must be the last stream group of the AVFormatContext.
*/
void ff_remove_stream_group(AVFormatContext *s, AVStreamGroup *stg);
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
......
......@@ -271,15 +271,23 @@ typedef struct MOVStreamContext {
typedef struct HEIFItem {
AVStream *st;
char *name;
int item_id;
int64_t extent_length;
int64_t extent_offset;
int64_t size;
int width;
int height;
int type;
int is_idat_relative;
} HEIFItem;
typedef struct HEIFGrid {
HEIFItem *item;
HEIFItem **tile_item_list;
int16_t *tile_id_list;
int nb_tiles;
} HEIFGrid;
typedef struct MOVContext {
const AVClass *class; ///< class for private options
AVFormatContext *fc;
......@@ -343,6 +351,10 @@ typedef struct MOVContext {
int cur_item_id;
HEIFItem *heif_item;
int nb_heif_item;
HEIFGrid *heif_grid;
int nb_heif_grid;
int thmb_item_id;
int64_t idat_offset;
int interleaved_read;
} MOVContext;
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
#include "version_major.h"
#define LIBAVFORMAT_VERSION_MINOR 22
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment