[vlc-commits] [Git][videolan/vlc][master] 4 commits: avcodec: move picture type to use sidedata on encoding

Jean-Baptiste Kempf gitlab at videolan.org
Sat Jun 19 09:22:08 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
8ed4f2a7 by Ilkka Ollakka at 2021-06-19T11:19:26+03:00
avcodec: move picture type to use sidedata on encoding

Sidedata AV_PKT_DATA_QUALITY_STATS has been present since 2015 on
version 56.51.100. Also previous coded_frame->pict_type doesn't seem to
be present anymore in ffmpeg master.

- - - - -
72bbf717 by Ilkka Ollakka at 2021-06-19T11:19:26+03:00
avcodec/vaapi: use AV_PIX_FMT_VAAPI

AV_PIX_FMT_VAAPI_VLD was deprecated in 2015 for avutil 54.13.100 and is
now removed from ffmpeg codebase. AV_PIX_FMT_VAAPI should be same value.

- - - - -
e7190e7a by Ilkka Ollakka at 2021-06-19T11:19:26+03:00
avcodec/subtitle: stop using removed setter for pkt timebase

Removed from ffmpeg repo in commit 23bb78d2ea4f0e3a0835744d59708efed50abccc.

- - - - -
c2ba623f by Ilkka Ollakka at 2021-06-19T11:19:26+03:00
avformat: remove pts hack from demuxing

pstream->cur_dts is no longer available from libavformat

- - - - -


7 changed files:

- modules/codec/avcodec/encoder.c
- modules/codec/avcodec/subtitle.c
- modules/codec/avcodec/va.c
- modules/codec/avcodec/va.h
- modules/codec/avcodec/vaapi.c
- modules/codec/avcodec/video.c
- modules/demux/avformat/mux.c


Changes:

=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -1110,6 +1110,29 @@ static block_t *vlc_av_packet_Wrap(AVPacket *packet, AVCodecContext *context )
     p_block->i_pts = VLC_TICK_0 + FROM_AVSCALE(packet->pts, context->time_base);
     p_block->i_dts = VLC_TICK_0 + FROM_AVSCALE(packet->dts, context->time_base);
 
+    uint8_t *av_packet_sidedata = av_packet_get_side_data(packet, AV_PKT_DATA_QUALITY_STATS, NULL);
+    if( av_packet_sidedata )
+    {
+       switch ( av_packet_sidedata[4] )
+       {
+       case AV_PICTURE_TYPE_I:
+       case AV_PICTURE_TYPE_SI:
+           p_block->i_flags |= BLOCK_FLAG_TYPE_I;
+           break;
+       case AV_PICTURE_TYPE_P:
+       case AV_PICTURE_TYPE_SP:
+           p_block->i_flags |= BLOCK_FLAG_TYPE_P;
+           break;
+       case AV_PICTURE_TYPE_B:
+       case AV_PICTURE_TYPE_BI:
+           p_block->i_flags |= BLOCK_FLAG_TYPE_B;
+           break;
+       default:
+           p_block->i_flags |= BLOCK_FLAG_TYPE_PB;
+       }
+
+    }
+
     return p_block;
 }
 
@@ -1241,27 +1264,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
 
     block_t *p_block = encode_avframe( p_enc, p_sys, frame );
 
-    if( p_block )
-    {
-       switch ( p_sys->p_context->coded_frame->pict_type )
-       {
-       case AV_PICTURE_TYPE_I:
-       case AV_PICTURE_TYPE_SI:
-           p_block->i_flags |= BLOCK_FLAG_TYPE_I;
-           break;
-       case AV_PICTURE_TYPE_P:
-       case AV_PICTURE_TYPE_SP:
-           p_block->i_flags |= BLOCK_FLAG_TYPE_P;
-           break;
-       case AV_PICTURE_TYPE_B:
-       case AV_PICTURE_TYPE_BI:
-           p_block->i_flags |= BLOCK_FLAG_TYPE_B;
-           break;
-       default:
-           p_block->i_flags |= BLOCK_FLAG_TYPE_PB;
-       }
-    }
-
     return p_block;
 }
 


=====================================
modules/codec/avcodec/subtitle.c
=====================================
@@ -113,7 +113,9 @@ int InitSubtitleDec(vlc_object_t *obj)
         }
     }
 
-#if LIBAVFORMAT_VERSION_MICRO >= 100
+#if LIBAVFORMAT_VERSION_MAJOR >= 59
+    context->pkt_timebase=AV_TIME_BASE_Q;
+#elif LIBAVFORMAT_VERSION_MICRO >= 100
     av_codec_set_pkt_timebase(context, AV_TIME_BASE_Q);
 #endif
 


=====================================
modules/codec/avcodec/va.c
=====================================
@@ -34,7 +34,7 @@ bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt)
 {
     switch (hwfmt)
     {
-        case AV_PIX_FMT_VAAPI_VLD:
+        case AV_PIX_FMT_VAAPI:
             switch (swfmt)
             {
                 case AV_PIX_FMT_YUVJ420P:


=====================================
modules/codec/avcodec/va.h
=====================================
@@ -85,7 +85,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
  * AV_PIX_FMT_D3D11VA_VLD - ID3D11VideoDecoderOutputView*
  * AV_PIX_FMT_DXVA2_VLD   - IDirect3DSurface9*
  * AV_PIX_FMT_VDPAU       - VdpVideoSurface
- * AV_PIX_FMT_VAAPI_VLD   - VASurfaceID
+ * AV_PIX_FMT_VAAPI       - VASurfaceID
  *
  * @param pic pointer to VLC picture containing the surface [IN/OUT]
  * @param surface pointer to the AVFrame data[0] and data[3] pointers [OUT]


=====================================
modules/codec/avcodec/vaapi.c
=====================================
@@ -242,7 +242,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, con
                   video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
     VLC_UNUSED(desc);
-    if ( hwfmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL ||
+    if ( hwfmt != AV_PIX_FMT_VAAPI || dec_device == NULL ||
         dec_device->type != VLC_DECODER_DEVICE_VAAPI)
         return VLC_EGENERIC;
 


=====================================
modules/codec/avcodec/video.c
=====================================
@@ -1627,7 +1627,7 @@ no_reuse:
         AV_PIX_FMT_D3D11VA_VLD,
         AV_PIX_FMT_DXVA2_VLD,
 #endif
-        AV_PIX_FMT_VAAPI_VLD,
+        AV_PIX_FMT_VAAPI,
         AV_PIX_FMT_VDPAU,
         AV_PIX_FMT_NONE,
     };


=====================================
modules/demux/avformat/mux.c
=====================================
@@ -405,14 +405,6 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
         pkt.dts = av_rescale_q( p_data->i_dts - VLC_TICK_0,
                                 VLC_TIME_BASE_Q, p_stream->time_base );
 
-    /* this is another hack to prevent libavformat from triggering the "non monotone timestamps" check in avformat/utils.c */
-    if( p_stream->cur_dts >= pkt.dts )
-    {
-        msg_Warn( p_mux, "Non monotonic stream %d(%4.4s) %"PRId64" >= %"PRId64,
-                  p_input->fmt.i_id, (const char *) &p_input->fmt.i_codec, p_stream->cur_dts, pkt.dts );
-        p_stream->cur_dts = pkt.dts - 1;
-    }
-
     if( av_write_frame( p_sys->oc, &pkt ) < 0 )
     {
         msg_Err( p_mux, "could not write frame (pts: %"PRId64", dts: %"PRId64") "
@@ -422,7 +414,6 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
         return VLC_EGENERIC;
     }
 
-    p_stream->cur_dts = pkt.dts;
 
     block_Release( p_data );
     return VLC_SUCCESS;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f919270b52c8133f2d6fefac00cd72ad857e71f7...c2ba623f0ad425e7743fca0bdc251d5bc9289e77

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f919270b52c8133f2d6fefac00cd72ad857e71f7...c2ba623f0ad425e7743fca0bdc251d5bc9289e77
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list