You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
Merge commit 'ca2f19b9cc37be509d85f05c8f902860475905f8'
* commit 'ca2f19b9cc37be509d85f05c8f902860475905f8': h264: switch to h2645_parse for NAL parsing Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
@@ -308,7 +308,9 @@ OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
|
|||||||
OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
|
OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
|
||||||
h264_direct.o h264_loopfilter.o \
|
h264_direct.o h264_loopfilter.o \
|
||||||
h264_mb.o h264_picture.o h264_ps.o \
|
h264_mb.o h264_picture.o h264_ps.o \
|
||||||
h264_refs.o h264_sei.o h264_slice.o h264data.o h264_parse.o
|
h264_refs.o h264_sei.o \
|
||||||
|
h264_slice.o h264data.o h264_parse.o \
|
||||||
|
h2645_parse.o
|
||||||
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
|
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
|
||||||
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
|
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
|
||||||
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
|
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "error_resilience.h"
|
#include "error_resilience.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "h264.h"
|
#include "h264.h"
|
||||||
|
#include "h2645_parse.h"
|
||||||
#include "h264data.h"
|
#include "h264data.h"
|
||||||
#include "h264chroma.h"
|
#include "h264chroma.h"
|
||||||
#include "h264_mvpred.h"
|
#include "h264_mvpred.h"
|
||||||
@@ -243,25 +244,6 @@ nsc:
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Identify the exact end of the bitstream
|
|
||||||
* @return the length of the trailing, or 0 if damaged
|
|
||||||
*/
|
|
||||||
static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
|
|
||||||
{
|
|
||||||
int v = *src;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
ff_tlog(h->avctx, "rbsp trailing %X\n", v);
|
|
||||||
|
|
||||||
for (r = 1; r < 9; r++) {
|
|
||||||
if (v & 1)
|
|
||||||
return r;
|
|
||||||
v >>= 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ff_h264_free_tables(H264Context *h)
|
void ff_h264_free_tables(H264Context *h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1179,85 +1161,39 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FF_API_CAP_VDPAU
|
||||||
static const uint8_t start_code[] = { 0x00, 0x00, 0x01 };
|
static const uint8_t start_code[] = { 0x00, 0x00, 0x01 };
|
||||||
|
#endif
|
||||||
|
|
||||||
static int get_bit_length(H264Context *h, const uint8_t *buf,
|
static int get_last_needed_nal(H264Context *h)
|
||||||
const uint8_t *ptr, int dst_length,
|
|
||||||
int i, int next_avc)
|
|
||||||
{
|
{
|
||||||
if ((h->workaround_bugs & FF_BUG_AUTODETECT) && i + 3 < next_avc &&
|
|
||||||
buf[i] == 0x00 && buf[i + 1] == 0x00 &&
|
|
||||||
buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
|
|
||||||
h->workaround_bugs |= FF_BUG_TRUNCATED;
|
|
||||||
|
|
||||||
if (!(h->workaround_bugs & FF_BUG_TRUNCATED))
|
|
||||||
while (dst_length > 0 && ptr[dst_length - 1] == 0)
|
|
||||||
dst_length--;
|
|
||||||
|
|
||||||
if (!dst_length)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 8 * dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_last_needed_nal(H264Context *h, const uint8_t *buf, int buf_size)
|
|
||||||
{
|
|
||||||
int next_avc = h->is_avc ? 0 : buf_size;
|
|
||||||
int nal_index = 0;
|
|
||||||
int buf_index = 0;
|
|
||||||
int nals_needed = 0;
|
int nals_needed = 0;
|
||||||
int first_slice = 0;
|
int first_slice = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
while(1) {
|
for (i = 0; i < h->pkt.nb_nals; i++) {
|
||||||
|
H2645NAL *nal = &h->pkt.nals[i];
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int nalsize = 0;
|
|
||||||
int dst_length, bit_length, consumed;
|
|
||||||
const uint8_t *ptr;
|
|
||||||
|
|
||||||
if (buf_index >= next_avc) {
|
|
||||||
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
|
|
||||||
if (nalsize < 0)
|
|
||||||
break;
|
|
||||||
next_avc = buf_index + nalsize;
|
|
||||||
} else {
|
|
||||||
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
|
|
||||||
if (buf_index >= buf_size)
|
|
||||||
break;
|
|
||||||
if (buf_index >= next_avc)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = ff_h264_decode_nal(h, &h->slice_ctx[0], buf + buf_index, &dst_length, &consumed,
|
|
||||||
next_avc - buf_index);
|
|
||||||
|
|
||||||
if (!ptr || dst_length < 0)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
|
|
||||||
buf_index += consumed;
|
|
||||||
|
|
||||||
bit_length = get_bit_length(h, buf, ptr, dst_length,
|
|
||||||
buf_index, next_avc);
|
|
||||||
nal_index++;
|
|
||||||
|
|
||||||
/* packets can sometimes contain multiple PPS/SPS,
|
/* packets can sometimes contain multiple PPS/SPS,
|
||||||
* e.g. two PAFF field pictures in one packet, or a demuxer
|
* e.g. two PAFF field pictures in one packet, or a demuxer
|
||||||
* which splits NALs strangely if so, when frame threading we
|
* which splits NALs strangely if so, when frame threading we
|
||||||
* can't start the next thread until we've read all of them */
|
* can't start the next thread until we've read all of them */
|
||||||
switch (h->nal_unit_type) {
|
switch (nal->type) {
|
||||||
case NAL_SPS:
|
case NAL_SPS:
|
||||||
case NAL_PPS:
|
case NAL_PPS:
|
||||||
nals_needed = nal_index;
|
nals_needed = i;
|
||||||
break;
|
break;
|
||||||
case NAL_DPA:
|
case NAL_DPA:
|
||||||
case NAL_IDR_SLICE:
|
case NAL_IDR_SLICE:
|
||||||
case NAL_SLICE:
|
case NAL_SLICE:
|
||||||
init_get_bits(&gb, ptr, bit_length);
|
init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
|
||||||
if (!get_ue_golomb_long(&gb) || // first_mb_in_slice
|
if (!get_ue_golomb_long(&gb) || // first_mb_in_slice
|
||||||
!first_slice ||
|
!first_slice ||
|
||||||
first_slice != h->nal_unit_type)
|
first_slice != nal->type)
|
||||||
nals_needed = nal_index;
|
nals_needed = i;
|
||||||
if (!first_slice)
|
if (!first_slice)
|
||||||
first_slice = h->nal_unit_type;
|
first_slice = nal->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,14 +1204,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
|
|||||||
int parse_extradata)
|
int parse_extradata)
|
||||||
{
|
{
|
||||||
AVCodecContext *const avctx = h->avctx;
|
AVCodecContext *const avctx = h->avctx;
|
||||||
H264SliceContext *sl;
|
unsigned context_count = 0;
|
||||||
int buf_index;
|
|
||||||
unsigned context_count;
|
|
||||||
int next_avc;
|
|
||||||
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
|
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
|
||||||
int nal_index;
|
|
||||||
int idr_cleared=0;
|
int idr_cleared=0;
|
||||||
int ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
h->nal_unit_type= 0;
|
h->nal_unit_type= 0;
|
||||||
|
|
||||||
@@ -1296,63 +1228,24 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
|
|||||||
h->is_avc = 1;
|
h->is_avc = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->active_thread_type & FF_THREAD_FRAME)
|
ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,
|
||||||
nals_needed = get_last_needed_nal(h, buf, buf_size);
|
h->nal_length_size, avctx->codec_id);
|
||||||
|
if (ret < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Error splitting the input into NAL units.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
if (avctx->active_thread_type & FF_THREAD_FRAME)
|
||||||
buf_index = 0;
|
nals_needed = get_last_needed_nal(h);
|
||||||
context_count = 0;
|
|
||||||
next_avc = h->is_avc ? 0 : buf_size;
|
for (i = 0; i < h->pkt.nb_nals; i++) {
|
||||||
nal_index = 0;
|
H2645NAL *nal = &h->pkt.nals[i];
|
||||||
for (;;) {
|
H264SliceContext *sl = &h->slice_ctx[context_count];
|
||||||
int consumed;
|
|
||||||
int dst_length;
|
|
||||||
int bit_length;
|
|
||||||
const uint8_t *ptr;
|
|
||||||
int nalsize = 0;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (buf_index >= next_avc) {
|
|
||||||
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
|
|
||||||
if (nalsize < 0)
|
|
||||||
break;
|
|
||||||
next_avc = buf_index + nalsize;
|
|
||||||
} else {
|
|
||||||
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
|
|
||||||
if (buf_index >= buf_size)
|
|
||||||
break;
|
|
||||||
if (buf_index >= next_avc)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sl = &h->slice_ctx[context_count];
|
|
||||||
|
|
||||||
ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
|
|
||||||
&consumed, next_avc - buf_index);
|
|
||||||
if (!ptr || dst_length < 0) {
|
|
||||||
ret = -1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
bit_length = get_bit_length(h, buf, ptr, dst_length,
|
|
||||||
buf_index + consumed, next_avc);
|
|
||||||
|
|
||||||
if (h->avctx->debug & FF_DEBUG_STARTCODE)
|
|
||||||
av_log(h->avctx, AV_LOG_DEBUG,
|
|
||||||
"NAL %d/%d at %d/%d length %d\n",
|
|
||||||
h->nal_unit_type, h->nal_ref_idc, buf_index, buf_size, dst_length);
|
|
||||||
|
|
||||||
if (h->is_avc && (nalsize != consumed) && nalsize)
|
|
||||||
av_log(h->avctx, AV_LOG_DEBUG,
|
|
||||||
"AVC: Consumed only %d bytes instead of %d\n",
|
|
||||||
consumed, nalsize);
|
|
||||||
|
|
||||||
buf_index += consumed;
|
|
||||||
nal_index++;
|
|
||||||
|
|
||||||
if (avctx->skip_frame >= AVDISCARD_NONREF &&
|
if (avctx->skip_frame >= AVDISCARD_NONREF &&
|
||||||
h->nal_ref_idc == 0 &&
|
nal->ref_idc == 0 && nal->type != NAL_SEI)
|
||||||
h->nal_unit_type != NAL_SEI)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
@@ -1360,7 +1253,7 @@ again:
|
|||||||
* parsing. Decoding slices is not possible in codec init
|
* parsing. Decoding slices is not possible in codec init
|
||||||
* with frame-mt */
|
* with frame-mt */
|
||||||
if (parse_extradata) {
|
if (parse_extradata) {
|
||||||
switch (h->nal_unit_type) {
|
switch (nal->type) {
|
||||||
case NAL_IDR_SLICE:
|
case NAL_IDR_SLICE:
|
||||||
case NAL_SLICE:
|
case NAL_SLICE:
|
||||||
case NAL_DPA:
|
case NAL_DPA:
|
||||||
@@ -1368,24 +1261,27 @@ again:
|
|||||||
case NAL_DPC:
|
case NAL_DPC:
|
||||||
av_log(h->avctx, AV_LOG_WARNING,
|
av_log(h->avctx, AV_LOG_WARNING,
|
||||||
"Ignoring NAL %d in global header/extradata\n",
|
"Ignoring NAL %d in global header/extradata\n",
|
||||||
h->nal_unit_type);
|
nal->type);
|
||||||
// fall through to next case
|
// fall through to next case
|
||||||
case NAL_AUXILIARY_SLICE:
|
case NAL_AUXILIARY_SLICE:
|
||||||
h->nal_unit_type = NAL_FF_IGNORE;
|
nal->type = NAL_FF_IGNORE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME these should stop being context-global variables
|
||||||
|
h->nal_ref_idc = nal->ref_idc;
|
||||||
|
h->nal_unit_type = nal->type;
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
|
switch (nal->type) {
|
||||||
switch (h->nal_unit_type) {
|
|
||||||
case NAL_IDR_SLICE:
|
case NAL_IDR_SLICE:
|
||||||
if ((ptr[0] & 0xFC) == 0x98) {
|
if ((nal->data[1] & 0xFC) == 0x98) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
|
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
|
||||||
h->next_outputed_poc = INT_MIN;
|
h->next_outputed_poc = INT_MIN;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (h->nal_unit_type != NAL_IDR_SLICE) {
|
if (nal->type != NAL_IDR_SLICE) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
"Invalid mix of idr and non-idr slices\n");
|
"Invalid mix of idr and non-idr slices\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -1402,9 +1298,8 @@ again:
|
|||||||
idr_cleared = 1;
|
idr_cleared = 1;
|
||||||
h->has_recovery_point = 1;
|
h->has_recovery_point = 1;
|
||||||
case NAL_SLICE:
|
case NAL_SLICE:
|
||||||
init_get_bits(&sl->gb, ptr, bit_length);
|
sl->gb = nal->gb;
|
||||||
|
if ( nals_needed >= i
|
||||||
if ( nals_needed >= nal_index
|
|
||||||
|| (!(avctx->active_thread_type & FF_THREAD_FRAME) && !context_count))
|
|| (!(avctx->active_thread_type & FF_THREAD_FRAME) && !context_count))
|
||||||
h->au_pps_id = -1;
|
h->au_pps_id = -1;
|
||||||
|
|
||||||
@@ -1424,17 +1319,16 @@ again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h->cur_pic_ptr->f->key_frame |=
|
h->cur_pic_ptr->f->key_frame |= (nal->type == NAL_IDR_SLICE);
|
||||||
(h->nal_unit_type == NAL_IDR_SLICE);
|
|
||||||
|
|
||||||
if (h->nal_unit_type == NAL_IDR_SLICE ||
|
if (nal->type == NAL_IDR_SLICE ||
|
||||||
(h->recovery_frame == h->frame_num && h->nal_ref_idc)) {
|
(h->recovery_frame == h->frame_num && nal->ref_idc)) {
|
||||||
h->recovery_frame = -1;
|
h->recovery_frame = -1;
|
||||||
h->cur_pic_ptr->recovered = 1;
|
h->cur_pic_ptr->recovered = 1;
|
||||||
}
|
}
|
||||||
// If we have an IDR, all frames after it in decoded order are
|
// If we have an IDR, all frames after it in decoded order are
|
||||||
// "recovered".
|
// "recovered".
|
||||||
if (h->nal_unit_type == NAL_IDR_SLICE)
|
if (nal->type == NAL_IDR_SLICE)
|
||||||
h->frame_recovered |= FRAME_RECOVERED_IDR;
|
h->frame_recovered |= FRAME_RECOVERED_IDR;
|
||||||
#if 1
|
#if 1
|
||||||
h->cur_pic_ptr->recovered |= h->frame_recovered;
|
h->cur_pic_ptr->recovered |= h->frame_recovered;
|
||||||
@@ -1444,7 +1338,7 @@ again:
|
|||||||
|
|
||||||
if (h->current_slice == 1) {
|
if (h->current_slice == 1) {
|
||||||
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS))
|
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS))
|
||||||
decode_postinit(h, nal_index >= nals_needed);
|
decode_postinit(h, i >= nals_needed);
|
||||||
|
|
||||||
if (h->avctx->hwaccel &&
|
if (h->avctx->hwaccel &&
|
||||||
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
|
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
|
||||||
@@ -1459,8 +1353,8 @@ again:
|
|||||||
if (sl->redundant_pic_count == 0) {
|
if (sl->redundant_pic_count == 0) {
|
||||||
if (avctx->hwaccel) {
|
if (avctx->hwaccel) {
|
||||||
ret = avctx->hwaccel->decode_slice(avctx,
|
ret = avctx->hwaccel->decode_slice(avctx,
|
||||||
&buf[buf_index - consumed],
|
nal->raw_data,
|
||||||
consumed);
|
nal->raw_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
#if FF_API_CAP_VDPAU
|
#if FF_API_CAP_VDPAU
|
||||||
@@ -1470,8 +1364,8 @@ again:
|
|||||||
start_code,
|
start_code,
|
||||||
sizeof(start_code));
|
sizeof(start_code));
|
||||||
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
|
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
|
||||||
&buf[buf_index - consumed],
|
nal->raw_data,
|
||||||
consumed);
|
nal->raw_size);
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
context_count++;
|
context_count++;
|
||||||
@@ -1483,34 +1377,27 @@ again:
|
|||||||
avpriv_request_sample(avctx, "data partitioning");
|
avpriv_request_sample(avctx, "data partitioning");
|
||||||
break;
|
break;
|
||||||
case NAL_SEI:
|
case NAL_SEI:
|
||||||
init_get_bits(&h->gb, ptr, bit_length);
|
h->gb = nal->gb;
|
||||||
ret = ff_h264_decode_sei(h);
|
ret = ff_h264_decode_sei(h);
|
||||||
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
case NAL_SPS:
|
case NAL_SPS:
|
||||||
init_get_bits(&h->gb, ptr, bit_length);
|
h->gb = nal->gb;
|
||||||
if (ff_h264_decode_seq_parameter_set(h, 0) >= 0)
|
if (ff_h264_decode_seq_parameter_set(h, 0) >= 0)
|
||||||
break;
|
break;
|
||||||
if (h->is_avc ? nalsize : 1) {
|
|
||||||
av_log(h->avctx, AV_LOG_DEBUG,
|
av_log(h->avctx, AV_LOG_DEBUG,
|
||||||
"SPS decoding failure, trying again with the complete NAL\n");
|
"SPS decoding failure, trying again with the complete NAL\n");
|
||||||
if (h->is_avc)
|
init_get_bits8(&h->gb, nal->raw_data + 1, nal->raw_size - 1);
|
||||||
av_assert0(next_avc - buf_index + consumed == nalsize);
|
|
||||||
if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
|
|
||||||
break;
|
|
||||||
init_get_bits(&h->gb, &buf[buf_index + 1 - consumed],
|
|
||||||
8*(next_avc - buf_index + consumed - 1));
|
|
||||||
if (ff_h264_decode_seq_parameter_set(h, 0) >= 0)
|
if (ff_h264_decode_seq_parameter_set(h, 0) >= 0)
|
||||||
break;
|
break;
|
||||||
}
|
h->gb = nal->gb;
|
||||||
init_get_bits(&h->gb, ptr, bit_length);
|
|
||||||
ff_h264_decode_seq_parameter_set(h, 1);
|
ff_h264_decode_seq_parameter_set(h, 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NAL_PPS:
|
case NAL_PPS:
|
||||||
init_get_bits(&h->gb, ptr, bit_length);
|
h->gb = nal->gb;
|
||||||
ret = ff_h264_decode_picture_parameter_set(h, bit_length);
|
ret = ff_h264_decode_picture_parameter_set(h, nal->size_bits);
|
||||||
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
@@ -1525,7 +1412,7 @@ again:
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
|
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
|
||||||
h->nal_unit_type, bit_length);
|
nal->type, nal->size_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context_count == h->max_contexts) {
|
if (context_count == h->max_contexts) {
|
||||||
@@ -1553,7 +1440,6 @@ again:
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (context_count) {
|
if (context_count) {
|
||||||
ret = ff_h264_execute_decode_slices(h, context_count);
|
ret = ff_h264_execute_decode_slices(h, context_count);
|
||||||
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
@@ -1564,7 +1450,6 @@ again:
|
|||||||
end:
|
end:
|
||||||
|
|
||||||
#if CONFIG_ERROR_RESILIENCE
|
#if CONFIG_ERROR_RESILIENCE
|
||||||
sl = h->slice_ctx;
|
|
||||||
/*
|
/*
|
||||||
* FIXME: Error handling code does not seem to support interlaced
|
* FIXME: Error handling code does not seem to support interlaced
|
||||||
* when slices span multiple rows
|
* when slices span multiple rows
|
||||||
@@ -1578,6 +1463,7 @@ end:
|
|||||||
* causes problems for the first MB line, too.
|
* causes problems for the first MB line, too.
|
||||||
*/
|
*/
|
||||||
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new && h->enable_er) {
|
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new && h->enable_er) {
|
||||||
|
H264SliceContext *sl = h->slice_ctx;
|
||||||
int use_last_pic = h->last_pic_for_ec.f->buf[0] && !sl->ref_count[0];
|
int use_last_pic = h->last_pic_for_ec.f->buf[0] && !sl->ref_count[0];
|
||||||
|
|
||||||
ff_h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
|
ff_h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
|
||||||
@@ -1609,7 +1495,7 @@ end:
|
|||||||
h->picture_structure == PICT_BOTTOM_FIELD);
|
h->picture_structure == PICT_BOTTOM_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret < 0) ? ret : buf_index;
|
return (ret < 0) ? ret : buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1860,6 +1746,8 @@ av_cold void ff_h264_free_context(H264Context *h)
|
|||||||
|
|
||||||
for (i = 0; i < MAX_PPS_COUNT; i++)
|
for (i = 0; i < MAX_PPS_COUNT; i++)
|
||||||
av_freep(h->pps_buffers + i);
|
av_freep(h->pps_buffers + i);
|
||||||
|
|
||||||
|
ff_h2645_packet_uninit(&h->pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int h264_decode_end(AVCodecContext *avctx)
|
static av_cold int h264_decode_end(AVCodecContext *avctx)
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "error_resilience.h"
|
#include "error_resilience.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "h264_parse.h"
|
#include "h264_parse.h"
|
||||||
|
#include "h2645_parse.h"
|
||||||
#include "h264chroma.h"
|
#include "h264chroma.h"
|
||||||
#include "h264dsp.h"
|
#include "h264dsp.h"
|
||||||
#include "h264pred.h"
|
#include "h264pred.h"
|
||||||
@@ -527,6 +528,8 @@ typedef struct H264Context {
|
|||||||
H264SliceContext *slice_ctx;
|
H264SliceContext *slice_ctx;
|
||||||
int nb_slice_ctx;
|
int nb_slice_ctx;
|
||||||
|
|
||||||
|
H2645Packet pkt;
|
||||||
|
|
||||||
int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
|
int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
|
||||||
|
|
||||||
/* coded dimensions -- 16 * mb w/h */
|
/* coded dimensions -- 16 * mb w/h */
|
||||||
|
Reference in New Issue
Block a user