* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "audioconvert.h"
+#include "channel_layout.h"
#include "buffer.h"
#include "common.h"
+#include "dict.h"
#include "frame.h"
#include "imgutils.h"
#include "mem.h"
frame->data[i] = frame->buf[i]->data;
}
- if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) {
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
av_buffer_unref(&frame->buf[1]);
frame->buf[1] = av_buffer_alloc(1024);
if (!frame->buf[1])
return AVERROR(EINVAL);
}
-int av_frame_ref(AVFrame *dst, AVFrame *src)
+int av_frame_ref(AVFrame *dst, const AVFrame *src)
{
int i, ret = 0;
return ret;
}
-AVFrame *av_frame_clone(AVFrame *src)
+AVFrame *av_frame_clone(const AVFrame *src)
{
AVFrame *ret = av_frame_alloc();
{
int i;
+ for (i = 0; i < frame->nb_side_data; i++) {
+ av_freep(&frame->side_data[i]->data);
+ av_dict_free(&frame->side_data[i]->metadata);
+ av_freep(&frame->side_data[i]);
+ }
+ av_freep(&frame->side_data);
+
for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)
av_buffer_unref(&frame->buf[i]);
for (i = 0; i < frame->nb_extended_buf; i++)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
{
- dst->key_frame = src->key_frame;
- dst->pict_type = src->pict_type;
- dst->sample_aspect_ratio = src->sample_aspect_ratio;
- dst->pts = src->pts;
- dst->interlaced_frame = src->interlaced_frame;
- dst->top_field_first = src->top_field_first;
- dst->sample_rate = src->sample_rate;
- dst->opaque = src->opaque;
- dst->pkt_pts = src->pkt_pts;
- dst->pkt_dts = src->pkt_dts;
- dst->quality = src->quality;
- dst->coded_picture_number = src->coded_picture_number;
+ int i;
+
+ dst->key_frame = src->key_frame;
+ dst->pict_type = src->pict_type;
+ dst->sample_aspect_ratio = src->sample_aspect_ratio;
+ dst->pts = src->pts;
+ dst->repeat_pict = src->repeat_pict;
+ dst->interlaced_frame = src->interlaced_frame;
+ dst->top_field_first = src->top_field_first;
+ dst->palette_has_changed = src->palette_has_changed;
+ dst->sample_rate = src->sample_rate;
+ dst->opaque = src->opaque;
+ dst->pkt_pts = src->pkt_pts;
+ dst->pkt_dts = src->pkt_dts;
+ dst->reordered_opaque = src->reordered_opaque;
+ dst->quality = src->quality;
+ dst->coded_picture_number = src->coded_picture_number;
dst->display_picture_number = src->display_picture_number;
+ dst->flags = src->flags;
+
+ memcpy(dst->error, src->error, sizeof(dst->error));
+
+ for (i = 0; i < src->nb_side_data; i++) {
+ const AVFrameSideData *sd_src = src->side_data[i];
+ AVFrameSideData *sd_dst = av_frame_new_side_data(dst, sd_src->type,
+ sd_src->size);
+ if (!sd_dst) {
+ for (i = 0; i < dst->nb_side_data; i++) {
+ av_freep(&dst->side_data[i]->data);
+ av_freep(&dst->side_data[i]);
+ av_dict_free(&dst->side_data[i]->metadata);
+ }
+ av_freep(&dst->side_data);
+ return AVERROR(ENOMEM);
+ }
+ memcpy(sd_dst->data, sd_src->data, sd_src->size);
+ av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
+ }
return 0;
}
}
return NULL;
}
+
+AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
+ enum AVFrameSideDataType type,
+ int size)
+{
+ AVFrameSideData *ret, **tmp;
+
+ if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
+ return NULL;
+
+ tmp = av_realloc(frame->side_data,
+ (frame->nb_side_data + 1) * sizeof(*frame->side_data));
+ if (!tmp)
+ return NULL;
+ frame->side_data = tmp;
+
+ ret = av_mallocz(sizeof(*ret));
+ if (!ret)
+ return NULL;
+
+ ret->data = av_malloc(size);
+ if (!ret->data) {
+ av_freep(&ret);
+ return NULL;
+ }
+
+ ret->size = size;
+ ret->type = type;
+
+ frame->side_data[frame->nb_side_data++] = ret;
+
+ return ret;
+}
+
+AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
+ enum AVFrameSideDataType type)
+{
+ int i;
+
+ for (i = 0; i < frame->nb_side_data; i++) {
+ if (frame->side_data[i]->type == type)
+ return frame->side_data[i];
+ }
+ return NULL;
+}