summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/ffmpeg/A02-png-sequences.patch37
-rw-r--r--libhb/decavcodec.c23
-rw-r--r--libhb/stream.c8
3 files changed, 24 insertions, 44 deletions
diff --git a/contrib/ffmpeg/A02-png-sequences.patch b/contrib/ffmpeg/A02-png-sequences.patch
deleted file mode 100644
index 6098c3150..000000000
--- a/contrib/ffmpeg/A02-png-sequences.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
-index 871f2b2..cba2e90 100644
---- a/libavcodec/pngdec.c
-+++ b/libavcodec/pngdec.c
-@@ -592,6 +592,24 @@ static int decode_frame(AVCodecContext *avctx,
- }
- }
- exit_loop:
-+/* ffmpeg-r18421 introduced support for CorePNG p-frames which
-+ * breaks raw png sequences created by QuickTime Pro.
-+ * since only the first png appears to be marked as PKT_FLAG_KEY
-+ * it means either QuickTime Pro is encoding incorrectly, or
-+ * this code block needs to find other criteria.
-+ *
-+ * As of ffmpeg-r19079 this patch should no longer be required.
-+ * It offers a similar solution; forces code block to be skipped.
-+ *
-+ * --kb
-+ *
-+ * The "fix" in r19079 was a hack placed in avcodec_decode_video.
-+ * avcodec_decode_video was obsoleted and no longer exists. The
-+ * "fix" disappeared with it.
-+ *
-+ * --jas
-+ */
-+#if 0
- /* handle p-frames only if a predecessor frame is available */
- if(s->last_picture->data[0] != NULL) {
- if(!(avpkt->flags & AV_PKT_FLAG_KEY)) {
-@@ -608,6 +626,7 @@ static int decode_frame(AVCodecContext *avctx,
- }
- }
- }
-+#endif
-
- *picture= *s->current_picture;
- *data_size = sizeof(AVFrame);
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 783342a44..a71c462b9 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -686,7 +686,7 @@ static void checkCadence( int * cadence, uint16_t flags, int64_t start )
* until enough packets have been decoded so that the timestamps can be
* correctly rewritten, if this is necessary.
*/
-static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequence, int64_t pts, int64_t dts )
+static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequence, int64_t pts, int64_t dts, uint8_t frametype )
{
hb_work_private_t *pv = w->private_data;
int got_picture, oldlevel = 0;
@@ -696,7 +696,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
if ( global_verbosity_level <= 1 )
{
oldlevel = av_log_get_level();
- av_log_set_level( AV_LOG_QUIET );
+ av_log_set_level( AV_LOG_VERBOSE );
}
av_init_packet( &avp );
@@ -704,6 +704,15 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
avp.size = size;
avp.pts = pts;
avp.dts = dts;
+ /*
+ * libav avcodec_decode_video2() needs AVPacket flagged with AV_PKT_FLAG_KEY
+ * for some codecs. For example, sequence of PNG in a mov container.
+ */
+ if ( frametype & HB_FRAME_KEY )
+ {
+ avp.flags |= AV_PKT_FLAG_KEY;
+ }
+
if ( avcodec_decode_video2( pv->context, &frame, &got_picture, &avp ) < 0 )
{
++pv->decode_errors;
@@ -870,7 +879,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
return got_picture;
}
-static void decodeVideo( hb_work_object_t *w, uint8_t *data, int size, int sequence, int64_t pts, int64_t dts )
+static void decodeVideo( hb_work_object_t *w, uint8_t *data, int size, int sequence, int64_t pts, int64_t dts, uint8_t frametype )
{
hb_work_private_t *pv = w->private_data;
@@ -903,14 +912,14 @@ static void decodeVideo( hb_work_object_t *w, uint8_t *data, int size, int seque
if ( pout_len > 0 )
{
- decodeFrame( w, pout, pout_len, sequence, parser_pts, parser_dts );
+ decodeFrame( w, pout, pout_len, sequence, parser_pts, parser_dts, frametype );
}
} while ( pos < size );
/* the stuff above flushed the parser, now flush the decoder */
if ( size <= 0 )
{
- while ( decodeFrame( w, NULL, 0, sequence, AV_NOPTS_VALUE, AV_NOPTS_VALUE ) )
+ while ( decodeFrame( w, NULL, 0, sequence, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0 ) )
{
}
flushDelayQueue( pv );
@@ -1115,7 +1124,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
{
if ( pv->context->codec != NULL )
{
- decodeVideo( w, in->data, in->size, in->sequence, pts, dts );
+ decodeVideo( w, in->data, in->size, in->sequence, pts, dts, in->s.frametype );
}
hb_list_add( pv->list, in );
*buf_out = link_buf_list( pv );
@@ -1163,7 +1172,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
pv->new_chap = in->s.new_chap;
pv->chap_time = pts >= 0? pts : pv->pts_next;
}
- decodeVideo( w, in->data, in->size, in->sequence, pts, dts );
+ decodeVideo( w, in->data, in->size, in->sequence, pts, dts, in->s.frametype );
hb_buffer_close( &in );
*buf_out = link_buf_list( pv );
return HB_WORK_OK;
diff --git a/libhb/stream.c b/libhb/stream.c
index 27e753f0f..4dd4a4e2a 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -5712,6 +5712,14 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream )
{
case AVMEDIA_TYPE_VIDEO:
buf->s.type = VIDEO_BUF;
+ /*
+ * libav avcodec_decode_video2() needs AVPacket flagged with AV_PKT_FLAG_KEY
+ * for some codecs. For example, sequence of PNG in a mov container.
+ */
+ if ( stream->ffmpeg_pkt->flags & AV_PKT_FLAG_KEY )
+ {
+ buf->s.frametype |= HB_FRAME_KEY;
+ }
break;
case AVMEDIA_TYPE_AUDIO: