diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-13 13:36:40 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-22 17:10:44 +0200 |
commit | 9effea016c177c44b4479524e6efd084267a2b1e (patch) | |
tree | f51b0cc72b897228b0afbdb2ed412078dc28cb61 /fftools/ffmpeg_filter.c | |
parent | dcfbfb417c3cc0473d887da70552026d07540232 (diff) | |
download | ffmpeg-9effea016c177c44b4479524e6efd084267a2b1e.tar.gz |
fftools/ffmpeg_filter: embed displaymatrix into private context
It has a small fixed size, so it is better to embed it rather than deal
with dynamic allocation.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c699431831..6f842f6b46 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -83,7 +83,8 @@ typedef struct InputFilterPriv { AVBufferRef *hw_frames_ctx; - int32_t *displaymatrix; + int displaymatrix_present; + int32_t displaymatrix[9]; // fallback parameters to use when no input is ever sent struct { @@ -302,7 +303,6 @@ void fg_free(FilterGraph **pfg) av_frame_free(&frame); av_fifo_freep2(&ifp->frame_queue); } - av_freep(&ifp->displaymatrix); if (ist->sub2video.sub_queue) { AVSubtitle sub; while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) @@ -1094,7 +1094,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, int32_t *displaymatrix = ifp->displaymatrix; double theta; - if (!displaymatrix) + if (!ifp->displaymatrix_present) displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL); theta = get_rotation(displaymatrix); @@ -1450,10 +1450,10 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr if (ret < 0) return ret; - av_freep(&ifp->displaymatrix); sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX); if (sd) - ifp->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9); + memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix)); + ifp->displaymatrix_present = !!sd; return 0; } @@ -1611,9 +1611,10 @@ int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) need_reinit = 1; if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { - if (!ifp->displaymatrix || memcmp(sd->data, ifp->displaymatrix, sizeof(int32_t) * 9)) + if (!ifp->displaymatrix_present || + memcmp(sd->data, ifp->displaymatrix, sizeof(ifp->displaymatrix))) need_reinit = 1; - } else if (ifp->displaymatrix) + } else if (ifp->displaymatrix_present) need_reinit = 1; if (need_reinit) { |