summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavcodec.c14
-rw-r--r--libhb/encavcodec.c53
-rw-r--r--libhb/enctheora.c7
-rw-r--r--libhb/encx264.c49
-rw-r--r--libhb/encx265.c13
-rw-r--r--libhb/muxavformat.c9
-rw-r--r--libhb/qsv_common.c5
-rw-r--r--libhb/stream.c5
8 files changed, 73 insertions, 82 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index eef1059df..ea0cad60d 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -957,16 +957,22 @@ static hb_buffer_t * cc_fill_buffer(hb_work_private_t *pv, uint8_t *cc, int size
static int get_frame_type(int type)
{
- switch(type)
+ switch (type)
{
- case AV_PICTURE_TYPE_I:
- return HB_FRAME_I;
case AV_PICTURE_TYPE_B:
return HB_FRAME_B;
+
+ case AV_PICTURE_TYPE_S:
case AV_PICTURE_TYPE_P:
+ case AV_PICTURE_TYPE_SP:
return HB_FRAME_P;
+
+ case AV_PICTURE_TYPE_BI:
+ case AV_PICTURE_TYPE_SI:
+ case AV_PICTURE_TYPE_I:
+ default:
+ return HB_FRAME_I;
}
- return 0;
}
/*
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index b5cee5c81..b17dd10ed 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -443,58 +443,36 @@ static void compute_dts_offset( hb_work_private_t * pv, hb_buffer_t * buf )
static uint8_t convert_pict_type( int pict_type, char pkt_flag_key, uint16_t* sflags )
{
+ uint16_t flags = 0;
uint8_t retval = 0;
- switch ( pict_type )
+ switch (pict_type)
{
- case AV_PICTURE_TYPE_P:
- {
- retval = HB_FRAME_P;
- } break;
-
case AV_PICTURE_TYPE_B:
- {
retval = HB_FRAME_B;
- } break;
+ break;
case AV_PICTURE_TYPE_S:
- {
- retval = HB_FRAME_P;
- } break;
-
+ case AV_PICTURE_TYPE_P:
case AV_PICTURE_TYPE_SP:
- {
retval = HB_FRAME_P;
- } break;
+ break;
+
case AV_PICTURE_TYPE_BI:
case AV_PICTURE_TYPE_SI:
case AV_PICTURE_TYPE_I:
- {
- *sflags |= HB_FRAME_REF;
- if ( pkt_flag_key )
- {
- retval = HB_FRAME_IDR;
- }
- else
- {
- retval = HB_FRAME_I;
- }
- } break;
-
default:
{
- if ( pkt_flag_key )
- {
- //buf->s.flags |= HB_FRAME_REF;
- *sflags |= HB_FRAME_REF;
- retval = HB_FRAME_KEY;
- }
- else
- {
- retval = HB_FRAME_REF;
- }
+ flags |= HB_FLAG_FRAMETYPE_REF;
+ retval = HB_FRAME_I;
} break;
}
+ if (pkt_flag_key)
+ {
+ flags |= HB_FLAG_FRAMETYPE_REF;
+ flags |= HB_FLAG_FRAMETYPE_KEY;
+ }
+ *sflags = flags;
return retval;
}
@@ -639,9 +617,8 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
buf->s.start = get_frame_start( pv, frameno );
buf->s.duration = get_frame_duration( pv, frameno );
buf->s.stop = buf->s.stop + buf->s.duration;
- buf->s.flags &= ~HB_FRAME_REF;
buf->s.frametype = convert_pict_type( pv->context->coded_frame->pict_type, pkt.flags & AV_PKT_FLAG_KEY, &buf->s.flags );
- if (buf->s.frametype & HB_FRAME_KEY)
+ if (buf->s.flags & HB_FLAG_FRAMETYPE_KEY)
{
hb_chapter_dequeue(pv->chapter_queue, buf);
}
diff --git a/libhb/enctheora.c b/libhb/enctheora.c
index 12438058f..f721269b5 100644
--- a/libhb/enctheora.c
+++ b/libhb/enctheora.c
@@ -358,7 +358,12 @@ int enctheoraWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
buf->f.fmt = AV_PIX_FMT_YUV420P;
buf->f.width = frame_width;
buf->f.height = frame_height;
- buf->s.frametype = ( th_packet_iskeyframe(&op) ) ? HB_FRAME_KEY : HB_FRAME_REF;
+ buf->s.flags = HB_FLAG_FRAMETYPE_REF;
+ buf->s.frametype = HB_FRAME_I;
+ if (th_packet_iskeyframe(&op))
+ {
+ buf->s.flags |= HB_FLAG_FRAMETYPE_KEY;
+ }
buf->s.start = in->s.start;
buf->s.stop = in->s.stop;
buf->s.duration = in->s.stop - in->s.start;
diff --git a/libhb/encx264.c b/libhb/encx264.c
index e74e4a39d..d5adfdd10 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -652,15 +652,11 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
w->config->h264.init_delay = -pic_out->i_dts;
}
- /* Decide what type of frame we have. */
- switch( pic_out->i_type )
+ /* Determine what type of frame we have. */
+ switch (pic_out->i_type)
{
case X264_TYPE_IDR:
- // Handled in b_keyframe check below.
- break;
-
- case X264_TYPE_I:
- buf->s.frametype = HB_FRAME_I;
+ buf->s.frametype = HB_FRAME_IDR;
break;
case X264_TYPE_P:
@@ -671,24 +667,20 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
buf->s.frametype = HB_FRAME_B;
break;
- /* This is for b-pyramid, which has reference b-frames
- However, it doesn't seem to ever be used... */
case X264_TYPE_BREF:
buf->s.frametype = HB_FRAME_BREF;
break;
- // If it isn't the above, what type of frame is it??
+ case X264_TYPE_I:
default:
- buf->s.frametype = 0;
+ buf->s.frametype = HB_FRAME_I;
break;
}
+ buf->s.flags = 0;
- // PIR has no IDR frames, but x264 marks recovery points
- // as keyframes. So fake an IDR at these points. This flag
- // is also set for real IDR frames.
if (pic_out->b_keyframe)
{
- buf->s.frametype = HB_FRAME_IDR;
+ buf->s.flags |= HB_FLAG_FRAMETYPE_KEY;
/* if we have a chapter marker pending and this
frame's presentation time stamp is at or after
the marker's time stamp, use this as the
@@ -728,17 +720,24 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
break;
}
- /* Since libx264 doesn't tell us when b-frames are
- themselves reference frames, figure it out on our own. */
- if( (buf->s.frametype == HB_FRAME_B) &&
- (nal[i].i_ref_idc != NAL_PRIORITY_DISPOSABLE) )
- buf->s.frametype = HB_FRAME_BREF;
-
- /* Expose disposable bit to muxer. */
- if( nal[i].i_ref_idc == NAL_PRIORITY_DISPOSABLE )
- buf->s.flags &= ~HB_FRAME_REF;
+ /*
+ * Expose disposable bit to muxer.
+ *
+ * Also, since libx264 doesn't tell us when B-frames are
+ * themselves reference frames, figure it out on our own.
+ */
+ if (nal[i].i_ref_idc == NAL_PRIORITY_DISPOSABLE)
+ {
+ buf->s.flags &= ~HB_FLAG_FRAMETYPE_REF;
+ }
else
- buf->s.flags |= HB_FRAME_REF;
+ {
+ if (buf->s.frametype == HB_FRAME_B)
+ {
+ buf->s.frametype = HB_FRAME_BREF;
+ }
+ buf->s.flags |= HB_FLAG_FRAMETYPE_REF;
+ }
buf->size += size;
}
diff --git a/libhb/encx265.c b/libhb/encx265.c
index eaf131d0b..9cb23bd08 100644
--- a/libhb/encx265.c
+++ b/libhb/encx265.c
@@ -384,8 +384,9 @@ static hb_buffer_t* nal_encode(hb_work_object_t *w,
{
return NULL;
}
-
+ buf->s.flags = 0;
buf->size = 0;
+
// copy the bitstream data
for (i = 0; i < nnal; i++)
{
@@ -406,11 +407,10 @@ static hb_buffer_t* nal_encode(hb_work_object_t *w,
switch (pic_out->sliceType)
{
case X265_TYPE_IDR:
+ buf->s.flags |= HB_FLAG_FRAMETYPE_REF;
+ buf->s.flags |= HB_FLAG_FRAMETYPE_KEY;
buf->s.frametype = HB_FRAME_IDR;
break;
- case X265_TYPE_I:
- buf->s.frametype = HB_FRAME_I;
- break;
case X265_TYPE_P:
buf->s.frametype = HB_FRAME_P;
break;
@@ -420,12 +420,13 @@ static hb_buffer_t* nal_encode(hb_work_object_t *w,
case X265_TYPE_BREF:
buf->s.frametype = HB_FRAME_BREF;
break;
+ case X265_TYPE_I:
default:
- buf->s.frametype = 0;
+ buf->s.frametype = HB_FRAME_I;
break;
}
- if (pic_out->sliceType == X265_TYPE_IDR)
+ if (buf->s.flags & HB_FLAG_FRAMETYPE_KEY)
{
hb_chapter_dequeue(pv->chapter_queue, buf);
}
diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c
index 47762721c..7b8bec67a 100644
--- a/libhb/muxavformat.c
+++ b/libhb/muxavformat.c
@@ -1161,12 +1161,13 @@ static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *bu
pkt.pts = pts;
pkt.duration = duration;
- if (track->type == MUX_TYPE_VIDEO && ((job->vcodec & HB_VCODEC_H264_MASK) ||
- (job->vcodec & HB_VCODEC_H265_MASK) ||
- (job->vcodec & HB_VCODEC_FFMPEG_MASK)))
+ if (track->type == MUX_TYPE_VIDEO)
{
- if (buf->s.frametype == HB_FRAME_IDR)
+ if ((buf->s.frametype == HB_FRAME_IDR) ||
+ (buf->s.flags & HB_FLAG_FRAMETYPE_KEY))
+ {
pkt.flags |= AV_PKT_FLAG_KEY;
+ }
}
else if (buf->s.frametype & HB_FRAME_KEY)
{
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
index 08d7f9c59..bb5dbc15a 100644
--- a/libhb/qsv_common.c
+++ b/libhb/qsv_common.c
@@ -2039,8 +2039,9 @@ uint8_t hb_qsv_frametype_xlat(uint16_t qsv_frametype, uint16_t *out_flags)
uint16_t flags = 0;
uint8_t frametype = 0;
- if (qsv_frametype & MFX_FRAMETYPE_IDR)
+ if (qsv_frametype & MFX_FRAMETYPE_IDR)
{
+ flags |= HB_FLAG_FRAMETYPE_KEY;
frametype = HB_FRAME_IDR;
}
else if (qsv_frametype & MFX_FRAMETYPE_I)
@@ -2058,7 +2059,7 @@ uint8_t hb_qsv_frametype_xlat(uint16_t qsv_frametype, uint16_t *out_flags)
if (qsv_frametype & MFX_FRAMETYPE_REF)
{
- flags |= HB_FRAME_REF;
+ flags |= HB_FLAG_FRAMETYPE_REF;
}
if (out_flags != NULL)
diff --git a/libhb/stream.c b/libhb/stream.c
index f5a6cb7df..2cdd4503d 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -5802,9 +5802,10 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream )
* 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 )
+ if (stream->ffmpeg_pkt->flags & AV_PKT_FLAG_KEY)
{
- buf->s.frametype |= HB_FRAME_KEY;
+ buf->s.flags = HB_FLAG_FRAMETYPE_KEY;
+ buf->s.frametype = HB_FRAME_I;
}
break;