[vlc-commits] transcode: refactor video init function
Ilkka Ollakka
git at videolan.org
Tue May 10 20:34:46 CEST 2016
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Mar 20 23:21:16 2016 +0200| [a2627abdbaaac1e5929e94077a7f4ba409d3b42c] | committer: Ilkka Ollakka
transcode: refactor video init function
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a2627abdbaaac1e5929e94077a7f4ba409d3b42c
---
modules/stream_out/transcode/video.c | 131 +++++++++++++++++++++-------------
1 file changed, 80 insertions(+), 51 deletions(-)
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 4d2c369..b9cae2b 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -341,19 +341,54 @@ static void conversion_video_filter_append( sout_stream_id_sys_t *id )
}
}
-static void transcode_video_encoder_init( sout_stream_t *p_stream,
- sout_stream_id_sys_t *id )
+static void transcode_video_framerate_init( sout_stream_t *p_stream,
+ sout_stream_id_sys_t *id,
+ const es_format_t *p_fmt_out )
{
- sout_stream_sys_t *p_sys = p_stream->p_sys;
-
- const es_format_t *p_fmt_out = &id->p_decoder->fmt_out;
- if( id->p_f_chain ) {
- p_fmt_out = filter_chain_GetFmtOut( id->p_f_chain );
- }
- if( id->p_uf_chain ) {
- p_fmt_out = filter_chain_GetFmtOut( id->p_uf_chain );
+ /* Handle frame rate conversion */
+ if( !id->p_encoder->fmt_out.video.i_frame_rate ||
+ !id->p_encoder->fmt_out.video.i_frame_rate_base )
+ {
+ if( p_fmt_out->video.i_frame_rate &&
+ p_fmt_out->video.i_frame_rate_base )
+ {
+ id->p_encoder->fmt_out.video.i_frame_rate =
+ p_fmt_out->video.i_frame_rate;
+ id->p_encoder->fmt_out.video.i_frame_rate_base =
+ p_fmt_out->video.i_frame_rate_base;
+ }
+ else
+ {
+ /* Pick a sensible default value */
+ id->p_encoder->fmt_out.video.i_frame_rate = ENC_FRAMERATE;
+ id->p_encoder->fmt_out.video.i_frame_rate_base = ENC_FRAMERATE_BASE;
+ }
}
+ id->p_encoder->fmt_in.video.i_frame_rate =
+ id->p_encoder->fmt_out.video.i_frame_rate;
+ id->p_encoder->fmt_in.video.i_frame_rate_base =
+ id->p_encoder->fmt_out.video.i_frame_rate_base;
+
+ vlc_ureduce( &id->p_encoder->fmt_in.video.i_frame_rate,
+ &id->p_encoder->fmt_in.video.i_frame_rate_base,
+ id->p_encoder->fmt_in.video.i_frame_rate,
+ id->p_encoder->fmt_in.video.i_frame_rate_base,
+ 0 );
+ msg_Dbg( p_stream, "source fps %u/%u, destination %u/%u",
+ id->p_decoder->fmt_out.video.i_frame_rate,
+ id->p_decoder->fmt_out.video.i_frame_rate_base,
+ id->p_encoder->fmt_in.video.i_frame_rate,
+ id->p_encoder->fmt_in.video.i_frame_rate_base );
+
+}
+
+static void transcode_video_size_init( sout_stream_t *p_stream,
+ sout_stream_id_sys_t *id,
+ const es_format_t *p_fmt_out )
+{
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
+
/* Calculate scaling
* width/height of source */
int i_src_visible_width = p_fmt_out->video.i_visible_width;
@@ -470,47 +505,19 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
i_src_visible_width, i_src_visible_height,
i_dst_visible_width, i_dst_visible_height
);
+};
- /* Handle frame rate conversion */
- if( !id->p_encoder->fmt_out.video.i_frame_rate ||
- !id->p_encoder->fmt_out.video.i_frame_rate_base )
- {
- if( p_fmt_out->video.i_frame_rate &&
- p_fmt_out->video.i_frame_rate_base )
- {
- id->p_encoder->fmt_out.video.i_frame_rate =
- p_fmt_out->video.i_frame_rate;
- id->p_encoder->fmt_out.video.i_frame_rate_base =
- p_fmt_out->video.i_frame_rate_base;
- }
- else
- {
- /* Pick a sensible default value */
- id->p_encoder->fmt_out.video.i_frame_rate = ENC_FRAMERATE;
- id->p_encoder->fmt_out.video.i_frame_rate_base = ENC_FRAMERATE_BASE;
- }
- }
-
- id->p_encoder->fmt_in.video.orientation =
- id->p_encoder->fmt_out.video.orientation =
- id->p_decoder->fmt_in.video.orientation;
-
- id->p_encoder->fmt_in.video.i_frame_rate =
- id->p_encoder->fmt_out.video.i_frame_rate;
- id->p_encoder->fmt_in.video.i_frame_rate_base =
- id->p_encoder->fmt_out.video.i_frame_rate_base;
-
- vlc_ureduce( &id->p_encoder->fmt_in.video.i_frame_rate,
- &id->p_encoder->fmt_in.video.i_frame_rate_base,
- id->p_encoder->fmt_in.video.i_frame_rate,
- id->p_encoder->fmt_in.video.i_frame_rate_base,
- 0 );
- msg_Dbg( p_stream, "source fps %u/%u, destination %u/%u",
- id->p_decoder->fmt_out.video.i_frame_rate,
- id->p_decoder->fmt_out.video.i_frame_rate_base,
- id->p_encoder->fmt_in.video.i_frame_rate,
- id->p_encoder->fmt_in.video.i_frame_rate_base );
+static void transcode_video_sar_init( sout_stream_t *p_stream,
+ sout_stream_id_sys_t *id,
+ const es_format_t *p_fmt_out )
+{
+ int i_src_visible_width = p_fmt_out->video.i_visible_width;
+ int i_src_visible_height = p_fmt_out->video.i_visible_height;
+ if (i_src_visible_width == 0)
+ i_src_visible_width = p_fmt_out->video.i_width;
+ if (i_src_visible_height == 0)
+ i_src_visible_height = p_fmt_out->video.i_height;
/* Check whether a particular aspect ratio was requested */
if( id->p_encoder->fmt_out.video.i_sar_num <= 0 ||
@@ -518,8 +525,8 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
{
vlc_ureduce( &id->p_encoder->fmt_out.video.i_sar_num,
&id->p_encoder->fmt_out.video.i_sar_den,
- (uint64_t)p_fmt_out->video.i_sar_num * i_src_visible_width * i_dst_visible_height,
- (uint64_t)p_fmt_out->video.i_sar_den * i_src_visible_height * i_dst_visible_width,
+ (uint64_t)p_fmt_out->video.i_sar_num * id->p_encoder->fmt_out.video.i_width * p_fmt_out->video.i_height,
+ (uint64_t)p_fmt_out->video.i_sar_den * id->p_encoder->fmt_out.video.i_height * p_fmt_out->video.i_width,
0 );
}
else
@@ -542,6 +549,28 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
}
+static void transcode_video_encoder_init( sout_stream_t *p_stream,
+ sout_stream_id_sys_t *id )
+{
+ const es_format_t *p_fmt_out = &id->p_decoder->fmt_out;
+ if( id->p_f_chain ) {
+ p_fmt_out = filter_chain_GetFmtOut( id->p_f_chain );
+ }
+ if( id->p_uf_chain ) {
+ p_fmt_out = filter_chain_GetFmtOut( id->p_uf_chain );
+ }
+
+ id->p_encoder->fmt_in.video.orientation =
+ id->p_encoder->fmt_out.video.orientation =
+ id->p_decoder->fmt_in.video.orientation;
+
+ transcode_video_framerate_init( p_stream, id, p_fmt_out );
+
+ transcode_video_size_init( p_stream, id, p_fmt_out );
+ transcode_video_sar_init( p_stream, id, p_fmt_out );
+
+}
+
static int transcode_video_encoder_open( sout_stream_t *p_stream,
sout_stream_id_sys_t *id )
{
More information about the vlc-commits
mailing list