lavc/decode: move sd_global_map to avcodec

It will be shared with encoding code.
release/7.1
Anton Khirnov 8 months ago
parent e1f384adbf
commit a3f4670943
  1. 14
      libavcodec/avcodec.c
  2. 16
      libavcodec/avcodec_internal.h
  3. 33
      libavcodec/decode.c

@ -54,6 +54,20 @@
*/
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
const SideDataMap ff_sd_global_map[] = {
{ AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN },
{ AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX },
{ AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL },
{ AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D },
{ AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE },
{ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
{ AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
{ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT },
{ AV_PKT_DATA_NB },
};
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
{
size_t i;

@ -25,8 +25,22 @@
#ifndef AVCODEC_AVCODEC_INTERNAL_H
#define AVCODEC_AVCODEC_INTERNAL_H
#include "libavutil/frame.h"
#include "packet.h"
struct AVCodecContext;
struct AVFrame;
typedef struct SideDataMap {
enum AVPacketSideDataType packet;
enum AVFrameSideDataType frame;
} SideDataMap;
/**
* A map between packet and frame side data types.
* Terminated with an entry where packet=AV_PKT_DATA_NB.
*/
extern const SideDataMap ff_sd_global_map[];
/**
* avcodec_receive_frame() implementation for decoders.

@ -1376,21 +1376,6 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
return av_packet_unpack_dictionary(side_metadata, size, frame_md);
}
static const struct {
enum AVPacketSideDataType packet;
enum AVFrameSideDataType frame;
} sd_global_map[] = {
{ AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN },
{ AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX },
{ AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL },
{ AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D },
{ AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE },
{ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
{ AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
{ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT },
};
int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
AVFrame *frame, const AVPacket *pkt)
{
@ -1414,13 +1399,13 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (int i = 0; i < FF_ARRAY_ELEMS(sd_global_map); i++) {
for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) {
size_t size;
const uint8_t *packet_sd = av_packet_get_side_data(pkt, sd_global_map[i].packet, &size);
const uint8_t *packet_sd = av_packet_get_side_data(pkt, ff_sd_global_map[i].packet, &size);
if (packet_sd) {
AVFrameSideData *frame_sd;
frame_sd = av_frame_new_side_data(frame, sd_global_map[i].frame, size);
frame_sd = av_frame_new_side_data(frame, ff_sd_global_map[i].frame, size);
if (!frame_sd)
return AVERROR(ENOMEM);
memcpy(frame_sd->data, packet_sd, size);
@ -1461,12 +1446,12 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
{
int ret;
for (int i = 0; i < FF_ARRAY_ELEMS(sd_global_map); i++) {
for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) {
const AVPacketSideData *packet_sd = ff_get_coded_side_data(avctx,
sd_global_map[i].packet);
ff_sd_global_map[i].packet);
if (packet_sd) {
AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
sd_global_map[i].frame,
ff_sd_global_map[i].frame,
packet_sd->size);
if (!frame_sd)
return AVERROR(ENOMEM);
@ -1758,9 +1743,9 @@ int ff_decode_preinit(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
for (unsigned j = 0; j < FF_ARRAY_ELEMS(sd_global_map); j++) {
if (sd_global_map[j].packet == val) {
val = sd_global_map[j].frame;
for (unsigned j = 0; ff_sd_global_map[j].packet < AV_PKT_DATA_NB; j++) {
if (ff_sd_global_map[j].packet == val) {
val = ff_sd_global_map[j].frame;
// this code will need to be changed when we have more than
// 64 frame side data types

Loading…
Cancel
Save