[vlc-devel] [PATCH] demux: mock: Add orientation option
Tanguy Dubroca
tanguy.dubroca at epita.fr
Wed Sep 16 17:33:28 CEST 2020
The var_Read_XXX functions are only called when the suboption overrides
a global
option. Here it is effectively a nop as video_orientation is only
defined as a
video suboption. The define to NULL is only to make the OVERRIDE_OPTION
macro
not complain. Also I chose to keep the argument as string as I wanted to be
able to check for invalid values (instead of providing a default
orientation).
On 9/16/20 5:14 PM, Thomas Guillem wrote:
>
> On Wed, Sep 16, 2020, at 16:01, Tanguy Dubroca wrote:
>> Usage: ./vlc 'mock://<mock options>;video_orientation=<orientation>'
>>
>> The video_orientation option is a simplification of the values from
>> video_orientation_t. The possible values are:
>>
>> - normal
>> - transposed / antitransposed
>> - hflipped / vflipped
>> - rotated_90 / rotated_180 / rotated_270
>>
>> Fix #25054
>> ---
>> modules/demux/mock.c | 39 ++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 38 insertions(+), 1 deletion(-)
>>
>> diff --git a/modules/demux/mock.c b/modules/demux/mock.c
>> index 3e40de176d..d2156132ea 100644
>> --- a/modules/demux/mock.c
>> +++ b/modules/demux/mock.c
>> @@ -118,6 +118,10 @@ var_Read_float(const char *psz)
>> return atof(psz);
>> }
>>
>> +typedef char* orientation_str_t;
>> +
>> +#define var_Read_orientation_str_t(psz) NULL
> Why not using video_orientation_t as a return value and implement var_Read_video_orientation_t()?
> And move OrientationFromString() to var_Read_video_orientation_t().
>
>> +
>> #define OPTIONS_AUDIO(Y) \
>> Y(audio, packetized, bool, add_bool, Bool, true) \
>> Y(audio, add_track_at, vlc_tick_t, add_integer, Integer,
>> VLC_TICK_INVALID) \
>> @@ -136,7 +140,8 @@ var_Read_float(const char *psz)
>> Y(video, width, unsigned, add_integer, Unsigned, 640) \
>> Y(video, height, unsigned, add_integer, Unsigned, 480) \
>> Y(video, frame_rate, unsigned, add_integer, Unsigned, 25) \
>> - Y(video, frame_rate_base, unsigned, add_integer, Unsigned, 1)
>> + Y(video, frame_rate_base, unsigned, add_integer, Unsigned, 1) \
>> + Y(video, orientation, orientation_str_t, add_string, String, NULL)
>>
>> #define OPTIONS_SUB(Y) \
>> Y(sub, packetized, bool, add_bool, Bool, true)\
>> @@ -620,6 +625,31 @@ CreateTrack(demux_t *demux, int i_cat, int id, int group)
>> return track;
>> }
>>
>> +static bool
>> +OrientationFromString(const char *orient, video_orientation_t *result)
>> +{
>> + if (!orient || !strcmp(orient, "normal"))
>> + *result = ORIENT_NORMAL;
>> + else if (!strcmp(orient, "transposed"))
>> + *result = ORIENT_TRANSPOSED;
>> + else if (!strcmp(orient, "antitransposed"))
>> + *result = ORIENT_ANTI_TRANSPOSED;
>> + else if (!strcmp(orient, "hflipped"))
>> + *result = ORIENT_HFLIPPED;
>> + else if (!strcmp(orient, "vflipped"))
>> + *result = ORIENT_VFLIPPED;
>> + else if (!strcmp(orient, "rotated_180"))
>> + *result = ORIENT_ROTATED_180;
>> + else if (!strcmp(orient, "rotated_270"))
>> + *result = ORIENT_ROTATED_270;
>> + else if (!strcmp(orient, "rotated_90"))
>> + *result = ORIENT_ROTATED_90;
>> + else
>> + return false;
>> +
>> + return true;
>> +}
>> +
>> static int
>> ConfigureVideoTrack(demux_t *demux,
>> const struct mock_video_options *options,
>> @@ -649,6 +679,12 @@ ConfigureVideoTrack(demux_t *demux,
>> return VLC_EGENERIC;
>> }
>>
>> + if (!OrientationFromString(options->orientation, &fmt->video.orientation))
>> + {
>> + msg_Err(demux, "Invalid orientation value %s", options->orientation);
>> + return VLC_EGENERIC;
>> + }
>> +
>> fmt->i_codec = chroma;
>> fmt->video.i_chroma = chroma;
>> fmt->video.i_width = fmt->video.i_visible_width = options->width;
>> @@ -959,6 +995,7 @@ Close(vlc_object_t *obj)
>> struct demux_sys *sys = demux->p_sys;
>>
>> free( sys->config );
>> + free( sys->video.orientation );
>>
>> struct mock_track *track;
>> vlc_vector_foreach(track, &sys->tracks)
>> --
>> 2.28.0
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list