Skip to content

Commit

Permalink
to_lavc_vid_conv: cp metadata out to tmp (refactor)
Browse files Browse the repository at this point in the history
Set metadata to out_frame only and copy it to tmp_frame (not to repeat
every assignment and potentially forgotting something).

\+ check tmp_frame afor allocation failure
  • Loading branch information
MartinPulec committed Oct 31, 2023
1 parent 37ae393 commit 5d3c31c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/libavcodec/to_lavc_vid_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,24 +1604,20 @@ struct to_lavc_vid_conv *to_lavc_vid_conv_init(codec_t in_pixfmt, int width, int
s->out_frame_parts[i] = av_frame_alloc();
}
s->out_frame = av_frame_alloc();
if (!s->out_frame) {
s->tmp_frame = av_frame_alloc();
if (!s->out_frame || !s->tmp_frame) {
log_msg(LOG_LEVEL_ERROR, "Could not allocate video frame\n");
to_lavc_vid_conv_destroy(&s);
return NULL;
}
s->tmp_frame = av_frame_alloc();
s->out_frame->opaque = s;
s->out_frame->pts = -1;
s->tmp_frame->pts = -1;

s->tmp_frame->format = s->out_frame->format = out_pixfmt;
s->tmp_frame->width = s->out_frame->width = width;
s->tmp_frame->height =s->out_frame->height = height;

s->out_frame->format = out_pixfmt;
s->out_frame->width = width;
s->out_frame->height = height;
get_av_pixfmt_details(out_pixfmt, &s->out_frame->colorspace,
&s->out_frame->color_range);
get_av_pixfmt_details(out_pixfmt, &s->tmp_frame->colorspace,
&s->tmp_frame->color_range);
av_frame_copy_props(s->tmp_frame, s->out_frame);
s->out_frame->opaque = s;

ret = av_frame_get_buffer(s->out_frame, 0);
if (ret < 0) {
Expand Down

0 comments on commit 5d3c31c

Please sign in to comment.