FFmpeg
Loading...
Searching...
No Matches
vf_thumbnail.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * Potential thumbnail lookup filter to reduce the risk of an inappropriate
24 * selection (such as a black frame) we could get with an absolute seek.
25 *
26 * Simplified version of algorithm by Vadim Zaliva <lord@crocodile.org>.
27 * @see http://notbrainsurgery.livejournal.com/29773.html
28 */
29
31#include "libavutil/mem.h"
32#include "libavutil/opt.h"
33#include "libavutil/pixdesc.h"
34#include "avfilter.h"
35#include "filters.h"
36#include "formats.h"
37
38#define HIST_SIZE (3*256)
39
41 AVFrame *buf; ///< cached frame
42 int histogram[HIST_SIZE]; ///< RGB color distribution histogram of the frame
43};
44
45typedef struct ThumbContext {
46 const AVClass *class;
47 int n; ///< current frame
49 int n_frames; ///< number of frames for analysis
50 struct thumb_frame *frames; ///< the n_frames frames
51 AVRational tb; ///< copy of the input timebase to ease access
52
55
56 int planewidth[4];
58 int planes;
61
62#define OFFSET(x) offsetof(ThumbContext, x)
63#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
64
65static const AVOption thumbnail_options[] = {
66 { "n", "set the frames batch size", OFFSET(n_frames), AV_OPT_TYPE_INT, {.i64=100}, 2, INT_MAX, FLAGS },
67 { "log", "force stats logging level", OFFSET(loglevel), AV_OPT_TYPE_INT, {.i64 = AV_LOG_INFO}, INT_MIN, INT_MAX, FLAGS, .unit = "level" },
68 { "quiet", "logging disabled", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_QUIET}, 0, 0, FLAGS, .unit = "level" },
69 { "info", "information logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_INFO}, 0, 0, FLAGS, .unit = "level" },
70 { "verbose", "verbose logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_VERBOSE}, 0, 0, FLAGS, .unit = "level" },
71 { NULL }
72};
73
75
77{
78 ThumbContext *s = ctx->priv;
79
80 s->frames = av_calloc(s->n_frames, sizeof(*s->frames));
81 if (!s->frames) {
83 "Allocation failure, try to lower the number of frames\n");
84 return AVERROR(ENOMEM);
85 }
86 av_log(ctx, AV_LOG_VERBOSE, "batch size: %d frames\n", s->n_frames);
87 return 0;
88}
89
90/**
91 * @brief Compute Sum-square deviation to estimate "closeness".
92 * @param hist color distribution histogram
93 * @param median average color distribution histogram
94 * @return sum of squared errors
95 */
96static double frame_sum_square_err(const int *hist, const double *median)
97{
98 int i;
99 double err, sum_sq_err = 0;
100
101 for (i = 0; i < HIST_SIZE; i++) {
102 err = median[i] - (double)hist[i];
103 sum_sq_err += err*err;
104 }
105 return sum_sq_err;
106}
107
109{
110 AVFrame *picref;
111 ThumbContext *s = ctx->priv;
112 int i, j, best_frame_idx = 0;
113 int nb_frames = s->n;
114 double avg_hist[HIST_SIZE] = {0}, sq_err, min_sq_err = -1;
115
116 // average histogram of the N frames
117 for (j = 0; j < FF_ARRAY_ELEMS(avg_hist); j++) {
118 for (i = 0; i < nb_frames; i++)
119 avg_hist[j] += (double)s->frames[i].histogram[j];
120 avg_hist[j] /= nb_frames;
121 }
122
123 // find the frame closer to the average using the sum of squared errors
124 for (i = 0; i < nb_frames; i++) {
125 sq_err = frame_sum_square_err(s->frames[i].histogram, avg_hist);
126 if (i == 0 || sq_err < min_sq_err)
127 best_frame_idx = i, min_sq_err = sq_err;
128 }
129
130 // free and reset everything (except the best frame buffer)
131 for (i = 0; i < nb_frames; i++) {
132 memset(s->frames[i].histogram, 0, sizeof(s->frames[i].histogram));
133 if (i != best_frame_idx)
134 av_frame_free(&s->frames[i].buf);
135 }
136 s->n = 0;
137
138 // raise the chosen one
139 picref = s->frames[best_frame_idx].buf;
140 if (s->loglevel != AV_LOG_QUIET)
141 av_log(ctx, s->loglevel, "frame id #%d (pts_time=%f) selected "
142 "from a set of %d images\n", best_frame_idx,
143 picref->pts * av_q2d(s->tb), nb_frames);
144 s->frames[best_frame_idx].buf = NULL;
145
146 return picref;
147}
148
149static void get_hist8(int *hist, const uint8_t *p, ptrdiff_t stride,
150 ptrdiff_t width, ptrdiff_t height)
151{
152 int shist[4][256] = {0};
153
154 const int width4 = width & ~3;
155 while (height--) {
156 for (int x = 0; x < width4; x += 4) {
157 const uint32_t v = AV_RN32(&p[x]);
158 shist[0][(uint8_t) (v >> 0)]++;
159 shist[1][(uint8_t) (v >> 8)]++;
160 shist[2][(uint8_t) (v >> 16)]++;
161 shist[3][(uint8_t) (v >> 24)]++;
162 }
163 /* handle tail */
164 for (int x = width4; x < width; x++)
165 hist[p[x]]++;
166 p += stride;
167 }
168
169 for (int i = 0; i < 4; i++) {
170 for (int j = 0; j < 256; j++)
171 hist[j] += shist[i][j];
172 }
173}
174
175static void get_hist16(int *hist, const uint8_t *p, ptrdiff_t stride,
176 ptrdiff_t width, ptrdiff_t height, int shift)
177{
178 int shist[4][256] = {0};
179
180 const int width4 = width & ~3;
181 while (height--) {
182 const uint16_t *p16 = (const uint16_t *) p;
183 for (int x = 0; x < width4; x += 4) {
184 const uint64_t v = AV_RN64(&p16[x]);
185 shist[0][(uint8_t) (v >> (shift + 0))]++;
186 shist[1][(uint8_t) (v >> (shift + 16))]++;
187 shist[2][(uint8_t) (v >> (shift + 32))]++;
188 shist[3][(uint8_t) (v >> (shift + 48))]++;
189 }
190 /* handle tail */
191 for (int x = width4; x < width; x++)
192 hist[(uint8_t) (p16[x] >> shift)]++;
193 p += stride;
194 }
195
196 for (int i = 0; i < 4; i++) {
197 for (int j = 0; j < 256; j++)
198 hist[j] += shist[i][j];
199 }
200}
201
202static int do_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
203{
204 ThumbContext *s = ctx->priv;
205 AVFrame *frame = arg;
206 int *hist = s->thread_histogram + HIST_SIZE * jobnr;
207 const int h = frame->height;
208 const int w = frame->width;
209 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs);
210 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs);
211 const uint8_t *p = frame->data[0] + slice_start * frame->linesize[0];
212
213 memset(hist, 0, sizeof(*hist) * HIST_SIZE);
214
215 switch (frame->format) {
216 case AV_PIX_FMT_RGB24:
217 case AV_PIX_FMT_BGR24:
218 for (int j = slice_start; j < slice_end; j++) {
219 for (int i = 0; i < w; i++) {
220 hist[0*256 + p[i*3 ]]++;
221 hist[1*256 + p[i*3 + 1]]++;
222 hist[2*256 + p[i*3 + 2]]++;
223 }
224 p += frame->linesize[0];
225 }
226 break;
227 case AV_PIX_FMT_RGB0:
228 case AV_PIX_FMT_BGR0:
229 case AV_PIX_FMT_RGBA:
230 case AV_PIX_FMT_BGRA:
231 for (int j = slice_start; j < slice_end; j++) {
232 for (int i = 0; i < w; i++) {
233 hist[0*256 + p[i*4 ]]++;
234 hist[1*256 + p[i*4 + 1]]++;
235 hist[2*256 + p[i*4 + 2]]++;
236 }
237 p += frame->linesize[0];
238 }
239 break;
240 case AV_PIX_FMT_0RGB:
241 case AV_PIX_FMT_0BGR:
242 case AV_PIX_FMT_ARGB:
243 case AV_PIX_FMT_ABGR:
244 for (int j = slice_start; j < slice_end; j++) {
245 for (int i = 0; i < w; i++) {
246 hist[0*256 + p[i*4 + 1]]++;
247 hist[1*256 + p[i*4 + 2]]++;
248 hist[2*256 + p[i*4 + 3]]++;
249 }
250 p += frame->linesize[0];
251 }
252 break;
253 default:
254 for (int plane = 0; plane < s->planes; plane++) {
255 const int slice_start = ff_slice_pos(s->planeheight[plane], jobnr, nb_jobs);
256 const int slice_end = ff_slice_pos(s->planeheight[plane], jobnr + 1, nb_jobs);
257 const uint8_t *p = frame->data[plane] + slice_start * frame->linesize[plane];
258 const ptrdiff_t linesize = frame->linesize[plane];
259 const int planewidth = s->planewidth[plane];
260 int *hhist = hist + 256 * plane;
261 if (s->bitdepth > 8) {
262 get_hist16(hhist, p, linesize, planewidth, slice_end - slice_start,
263 s->bitdepth - 8);
264 } else {
265 get_hist8(hhist, p, linesize, planewidth, slice_end - slice_start);
266 }
267 }
268 break;
269 }
270
271 return 0;
272}
273
275{
276 AVFilterContext *ctx = inlink->dst;
277 ThumbContext *s = ctx->priv;
278 AVFilterLink *outlink = ctx->outputs[0];
279 int *hist = s->frames[s->n].histogram;
280
281 // keep a reference of each frame
282 s->frames[s->n].buf = frame;
283
285 FFMIN(frame->height, s->nb_threads));
286
287 // update current frame histogram
288 for (int j = 0; j < FFMIN(frame->height, s->nb_threads); j++) {
289 int *thread_histogram = s->thread_histogram + HIST_SIZE * j;
290
291 for (int i = 0; i < HIST_SIZE; i++)
292 hist[i] += thread_histogram[i];
293 }
294
295 // no selection until the buffer of N frames is filled up
296 s->n++;
297 if (s->n < s->n_frames)
298 return 0;
299
300 return ff_filter_frame(outlink, get_best_frame(ctx));
301}
302
304{
305 int i;
306 ThumbContext *s = ctx->priv;
307 for (i = 0; i < s->n_frames && s->frames && s->frames[i].buf; i++)
308 av_frame_free(&s->frames[i].buf);
309 av_freep(&s->frames);
310 av_freep(&s->thread_histogram);
311}
312
314{
315 AVFilterContext *ctx = link->src;
316 ThumbContext *s = ctx->priv;
317 int ret = ff_request_frame(ctx->inputs[0]);
318
319 if (ret == AVERROR_EOF && s->n) {
320 ret = ff_filter_frame(link, get_best_frame(ctx));
321 if (ret < 0)
322 return ret;
323 ret = AVERROR_EOF;
324 }
325 if (ret < 0)
326 return ret;
327 return 0;
328}
329
330static int config_props(AVFilterLink *inlink)
331{
332 AVFilterContext *ctx = inlink->dst;
333 ThumbContext *s = ctx->priv;
335
336 s->nb_threads = ff_filter_get_nb_threads(ctx);
337 s->thread_histogram = av_calloc(HIST_SIZE, s->nb_threads * sizeof(*s->thread_histogram));
338 if (!s->thread_histogram)
339 return AVERROR(ENOMEM);
340
341 s->tb = inlink->time_base;
342 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
343 s->planewidth[0] = s->planewidth[3] = inlink->w;
344 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
345 s->planeheight[0] = s->planeheight[3] = inlink->h;
346 s->planes = av_pix_fmt_count_planes(inlink->format) - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
347 s->bitdepth = desc->comp[0].depth;
348
349 return 0;
350}
351
360
362 AVFilterFormatsConfig **cfg_in,
363 AVFilterFormatsConfig **cfg_out)
364{
367
369 if (!formats)
370 return AVERROR(ENOMEM);
371
372
373 while ((desc = av_pix_fmt_desc_next(desc))) {
374 int color_comps = desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
375 if ((color_comps == 1 || (desc->flags & AV_PIX_FMT_FLAG_PLANAR)) &&
377 (desc->comp[0].depth <= 8 || HAVE_BIGENDIAN == !!(desc->flags & AV_PIX_FMT_FLAG_BE)) &&
378 (desc->nb_components < 3 || desc->comp[1].plane != desc->comp[2].plane) &&
379 desc->comp[0].depth <= 16)
380 {
382 if (ret < 0)
383 return ret;
384 }
385 }
386
387 return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
388}
389
391 {
392 .name = "default",
393 .type = AVMEDIA_TYPE_VIDEO,
394 .config_props = config_props,
395 .filter_frame = filter_frame,
396 },
397};
398
400 {
401 .name = "default",
402 .type = AVMEDIA_TYPE_VIDEO,
403 .request_frame = request_frame,
404 },
405};
406
408 .p.name = "thumbnail",
409 .p.description = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."),
410 .p.priv_class = &thumbnail_class,
413 .priv_size = sizeof(ThumbContext),
414 .init = init,
415 .uninit = uninit,
419};
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
const FFFilter ff_vf_thumbnail
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition avfilter.c:483
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1696
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:846
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
static AVFrame * frame
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define HIST_SIZE
Definition f_ebur128.c:51
int ff_set_common_formats2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, AVFilterFormats *formats)
Definition formats.c:1137
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition formats.c:571
av_warn_unused_result AVFilterFormats * ff_make_pixel_format_list(const enum AVPixelFormat *fmts)
Create a list of supported pixel formats.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition avfilter.h:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
#define AV_LOG_QUIET
Print no output.
Definition log.h:192
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AV_RN64(p)
#define AV_RN32(p)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int shift(int a, int b)
Definition bonk.c:261
const char * arg
Definition jacosubdec.c:65
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:763
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
const char * desc
Definition libsvtav1.c:83
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition mpeg12dec.c:1697
AVOptions.
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition pixdesc.c:3479
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition pixdesc.c:3467
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition pixdesc.h:147
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition pixdesc.h:124
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition pixdesc.h:158
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition pixdesc.h:132
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition pixdesc.h:116
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition pixfmt.h:263
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition pixfmt.h:262
formats
Definition signature.h:47
#define FF_ARRAY_ELEMS(a)
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
Lists of formats / etc.
Definition avfilter.h:120
A list of supported formats for one end of a filter link.
Definition formats.h:64
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
Rational number (pair of numerator and denominator).
Definition rational.h:58
AVRational tb
copy of the input timebase to ease access
struct thumb_frame * frames
the n_frames frames
int * thread_histogram
int n
current frame
int planewidth[4]
int n_frames
number of frames for analysis
int planeheight[4]
AVFrame * buf
cached frame
int histogram[HIST_SIZE]
RGB color distribution histogram of the frame.
#define stride
#define av_freep(p)
#define av_log(a,...)
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static int do_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static AVFrame * get_best_frame(AVFilterContext *ctx)
static int do_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static enum AVPixelFormat packed_rgb_fmts[]
static const AVOption thumbnail_options[]
static void get_hist8(int *hist, const uint8_t *p, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static int request_frame(AVFilterLink *link)
static const AVFilterPad thumbnail_inputs[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_props(AVFilterLink *inlink)
static av_cold void uninit(AVFilterContext *ctx)
static double frame_sum_square_err(const int *hist, const double *median)
Compute Sum-square deviation to estimate "closeness".
static void get_hist16(int *hist, const uint8_t *p, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, int shift)
#define OFFSET(x)
static const AVFilterPad thumbnail_outputs[]
#define HIST_SIZE
static int thumbnail(AVFilterContext *ctx, int *histogram, AVFrame *in)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition dec.c:844