static int
tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
-{
- uint8_t *qsdata = NULL;
-#if LIBAVCODEC_VERSION_MAJOR < 59
- int qsdata_size = 0;
-#else
- size_t qsdata_size = 0;
-#endif
-
- enum AVPictureType pict_type = AV_PICTURE_TYPE_NONE;
+{
+ enum AVPictureType pict_type = self->oavframe->pict_type;
- if (avpkt->flags & AV_PKT_FLAG_KEY) {
+ if (pict_type == AV_PICTURE_TYPE_NONE && avpkt->flags & AV_PKT_FLAG_KEY) {
pict_type = AV_PICTURE_TYPE_I;
}
- else {
- qsdata = av_packet_get_side_data(avpkt, AV_PKT_DATA_QUALITY_STATS,
- &qsdata_size);
- if (qsdata && qsdata_size >= 5) {
- pict_type = qsdata[4];
+ if (pict_type == AV_PICTURE_TYPE_NONE) {
+ // some codecs do not set pict_type but set key_frame, in this case,
+ // we assume that when key_frame == 1 the frame is an I-frame
+ // (all the others are assumed to be P-frames)
+ if (self->oavframe->key_frame) {
+ pict_type = AV_PICTURE_TYPE_I;
}
-#if FF_API_CODED_FRAME
- else if (self->oavctx->coded_frame) {
- // some codecs do not set pict_type but set key_frame, in this case,
- // we assume that when key_frame == 1 the frame is an I-frame
- // (all the others are assumed to be P-frames)
- if (!(pict_type = self->oavctx->coded_frame->pict_type)) {
- if (self->oavctx->coded_frame->key_frame) {
- pict_type = AV_PICTURE_TYPE_I;
- }
- else {
- pict_type = AV_PICTURE_TYPE_P;
- }
- }
+ else {
+ pict_type = AV_PICTURE_TYPE_P;
}
-#endif
}
+
switch (pict_type) {
case AV_PICTURE_TYPE_I:
pkt->v.pkt_frametype = PKT_I_FRAME;
case AV_PICTURE_TYPE_B:
pkt->v.pkt_frametype = PKT_B_FRAME;
break;
+ case AV_PICTURE_TYPE_NONE:
+ break;
default:
tvh_context_log(self, LOG_WARNING, "unknown picture type: %d",
pict_type);
+++ /dev/null
-diff -urN ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c ./libavcodec/vaapi_encode.c
---- ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c 2016-06-27 01:54:29.000000000 +0200
-+++ ./libavcodec/vaapi_encode.c 2016-08-31 11:53:21.159413291 +0200
-@@ -26,6 +26,8 @@
-
- #include "vaapi_encode.h"
- #include "avcodec.h"
-+#include "internal.h"
-+#include "packet_internal.h"
-
- const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[] = {
- HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI),
-@@ -586,7 +588,7 @@ static int vaapi_encode_output(AVCodecCo
- VAStatus vas;
- int total_size = 0;
- uint8_t *ptr;
-- int err;
-+ int err, pict_type;
-
- err = vaapi_encode_wait(avctx, pic);
- if (err < 0)
-@@ -624,6 +626,28 @@ static int vaapi_encode_output(AVCodecCo
-
- pkt->pts = pic->pts;
-
-+ switch (pic->type) {
-+ case PICTURE_TYPE_IDR:
-+ case PICTURE_TYPE_I:
-+ pict_type = AV_PICTURE_TYPE_I;
-+ break;
-+ case PICTURE_TYPE_P:
-+ pict_type = AV_PICTURE_TYPE_P;
-+ break;
-+ case PICTURE_TYPE_B:
-+ pict_type = AV_PICTURE_TYPE_B;
-+ break;
-+ default:
-+ pict_type = AV_PICTURE_TYPE_NONE;
-+ break;
-+ }
-+#if FF_API_CODED_FRAME
-+FF_DISABLE_DEPRECATION_WARNINGS
-+ avctx->coded_frame->pict_type = pict_type;
-+FF_ENABLE_DEPRECATION_WARNINGS
-+#endif
-+ ff_side_data_set_encoder_stats(pkt, -1, NULL, 0, pict_type);
-+
- vas = vaUnmapBuffer(ctx->hwctx->display, pic->output_buffer);
- if (vas != VA_STATUS_SUCCESS) {
- av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "