FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_setparams.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/pixfmt.h"
20 #include "libavutil/opt.h"
21 #include "avfilter.h"
22 #include "internal.h"
23 #include "video.h"
24 
25 typedef struct SetParamsContext {
26  const AVClass *class;
29 
30 #define OFFSET(x) offsetof(SetParamsContext, x)
31 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
32 
33 static const AVOption setrange_options[] = {
34  {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1},-1, AVCOL_RANGE_NB-1, FLAGS, "range"},
35  {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, "range"},
36  {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, "range"},
37  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, "range"},
38  {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
39  {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
40  {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
41  {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range"},
42  {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range"},
43  {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range"},
44  {NULL}
45 };
46 
47 AVFILTER_DEFINE_CLASS(setrange);
48 
49 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
50 {
51  AVFilterContext *ctx = inlink->dst;
52  SetParamsContext *s = ctx->priv;
53 
54  if (s->color_range >= 0)
55  frame->color_range = s->color_range;
56  return ff_filter_frame(ctx->outputs[0], frame);
57 }
58 
59 static const AVFilterPad inputs[] = {
60  {
61  .name = "default",
62  .type = AVMEDIA_TYPE_VIDEO,
63  .filter_frame = filter_frame,
64  },
65  { NULL }
66 };
67 
68 static const AVFilterPad outputs[] = {
69  {
70  .name = "default",
71  .type = AVMEDIA_TYPE_VIDEO,
72  },
73  { NULL }
74 };
75 
77  .name = "setrange",
78  .description = NULL_IF_CONFIG_SMALL("Force color range for the output video frame."),
79  .priv_size = sizeof(SetParamsContext),
80  .priv_class = &setrange_class,
81  .inputs = inputs,
82  .outputs = outputs,
83 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
AVOption.
Definition: opt.h:246
Main libavfilter public API header.
static const AVOption setrange_options[]
Definition: vf_setparams.c:33
#define OFFSET(x)
Definition: vf_setparams.c:30
color_range
const char * name
Pad name.
Definition: internal.h:60
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVOptions.
static AVFrame * frame
Not part of ABI.
Definition: pixfmt.h:500
static const AVFilterPad inputs[]
Definition: vf_setparams.c:59
A filter pad used for either input or output.
Definition: internal.h:54
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * priv
private data for use by the filter
Definition: avfilter.h:353
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:463
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_setparams.c:49
AVFormatContext * ctx
Definition: movenc.c:48
static const AVFilterPad outputs[]
Definition: vf_setparams.c:68
AVFILTER_DEFINE_CLASS(setrange)
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:499
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
const char * name
Filter name.
Definition: avfilter.h:148
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:498
#define FLAGS
Definition: vf_setparams.c:31
pixel format definitions
An instance of a filter.
Definition: avfilter.h:338
AVFilter ff_vf_setrange
Definition: vf_setparams.c:76
internal API functions