#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
+#include "libavutil/stereo3d.h"
#include "internal.h"
#include "cabac.h"
#include "cabac_functions.h"
int off = offsetof(Picture, tf) + sizeof(pic->tf);
int i;
- if (!pic->f.data[0])
+ if (!pic->f.buf[0])
return;
ff_thread_release_buffer(h->avctx, &pic->tf);
/* release non reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (h->DPB[i].f.data[0] && !h->DPB[i].reference &&
+ if (h->DPB[i].f.buf[0] && !h->DPB[i].reference &&
(remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
unref_picture(h, &h->DPB[i]);
}
static inline int pic_is_unused(H264Context *h, Picture *pic)
{
- if (pic->f.data[0] == NULL)
+ if (!pic->f.buf[0])
return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1;
if (!h->DPB)
return AVERROR(ENOMEM);
for (i = 0; i < MAX_PICTURE_COUNT; i++)
- avcodec_get_frame_defaults(&h->DPB[i].f);
- avcodec_get_frame_defaults(&h->cur_pic.f);
+ av_frame_unref(&h->DPB[i].f);
+ av_frame_unref(&h->cur_pic.f);
}
return 0;
h->context_initialized = 0;
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
- avcodec_get_frame_defaults(&h->cur_pic.f);
+ av_frame_unref(&h->cur_pic.f);
h->cur_pic.tf.f = &h->cur_pic.f;
h->avctx = dst;
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
unref_picture(h, &h->DPB[i]);
- if (h1->DPB[i].f.data[0] &&
+ if (h1->DPB[i].f.buf[0] &&
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret;
}
}
}
+ if (h->sei_frame_packing_present &&
+ h->frame_packing_arrangement_type >= 0 &&
+ h->frame_packing_arrangement_type <= 6 &&
+ h->content_interpretation_type > 0 &&
+ h->content_interpretation_type < 3) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(&cur->f);
+ if (!stereo)
+ return;
+
+ switch (h->frame_packing_arrangement_type) {
+ case 0:
+ stereo->type = AV_STEREO3D_CHECKERBOARD;
+ break;
+ case 1:
+ stereo->type = AV_STEREO3D_LINES;
+ break;
+ case 2:
+ stereo->type = AV_STEREO3D_COLUMNS;
+ break;
+ case 3:
+ if (h->quincunx_subsampling)
+ stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ else
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 4:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case 5:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+ case 6:
+ stereo->type = AV_STEREO3D_2D;
+ break;
+ }
+
+ if (h->content_interpretation_type == 2)
+ stereo->flags = AV_STEREO3D_FLAG_INVERT;
+ }
+
// FIXME do something with unavailable reference frames
/* Sort B-frames into display order */
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
- if (h->sps.bit_depth_luma != h->sps.bit_depth_chroma) {
- avpriv_request_sample(h->avctx,
- "Different chroma and luma bit depth");
- return AVERROR_PATCHWELCOME;
- }
-
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
int ff_set_ref_count(H264Context *h)
{
+ int ref_count[2], list_count;
int num_ref_idx_active_override_flag, max_refs;
// set defaults, might be overridden a few lines later
- h->ref_count[0] = h->pps.ref_count[0];
- h->ref_count[1] = h->pps.ref_count[1];
+ ref_count[0] = h->pps.ref_count[0];
+ ref_count[1] = h->pps.ref_count[1];
if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
num_ref_idx_active_override_flag = get_bits1(&h->gb);
if (num_ref_idx_active_override_flag) {
- h->ref_count[0] = get_ue_golomb(&h->gb) + 1;
- if (h->ref_count[0] < 1)
+ ref_count[0] = get_ue_golomb(&h->gb) + 1;
+ if (ref_count[0] < 1)
return AVERROR_INVALIDDATA;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- h->ref_count[1] = get_ue_golomb(&h->gb) + 1;
- if (h->ref_count[1] < 1)
+ ref_count[1] = get_ue_golomb(&h->gb) + 1;
+ if (ref_count[1] < 1)
return AVERROR_INVALIDDATA;
}
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->list_count = 2;
+ list_count = 2;
else
- h->list_count = 1;
+ list_count = 1;
} else {
- h->list_count = 0;
- h->ref_count[0] = h->ref_count[1] = 0;
+ list_count = 0;
+ ref_count[0] = ref_count[1] = 0;
}
max_refs = h->picture_structure == PICT_FRAME ? 16 : 32;
- if (h->ref_count[0] > max_refs || h->ref_count[1] > max_refs) {
+ if (ref_count[0] > max_refs || ref_count[1] > max_refs) {
av_log(h->avctx, AV_LOG_ERROR, "reference overflow\n");
h->ref_count[0] = h->ref_count[1] = 0;
return AVERROR_INVALIDDATA;
}
+ if (list_count != h->list_count ||
+ ref_count[0] != h->ref_count[0] ||
+ ref_count[1] != h->ref_count[1]) {
+ h->ref_count[0] = ref_count[0];
+ h->ref_count[1] = ref_count[1];
+ h->list_count = list_count;
+ return 1;
+ }
+
return 0;
}
* since that can modify s->current_picture_ptr. */
if (h0->first_field) {
assert(h0->cur_pic_ptr);
- assert(h0->cur_pic_ptr->f.data[0]);
+ assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
* frame, or to allocate a new one. */
if (h0->first_field) {
assert(h0->cur_pic_ptr);
- assert(h0->cur_pic_ptr->f.data[0]);
+ assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
ret = ff_set_ref_count(h);
if (ret < 0)
return ret;
+ else if (ret == 1)
+ default_ref_list_done = 0;
if (!default_ref_list_done)
ff_h264_fill_default_ref_list(h);
H264Context *hx;
int i;
+ if (h->mb_y >= h->mb_height) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Input contains more MB rows than the frame height.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
if (h->avctx->hwaccel)
return 0;
if (context_count == 1) {
h->workaround_bugs |= FF_BUG_TRUNCATED;
if (!(h->workaround_bugs & FF_BUG_TRUNCATED))
- while (ptr[dst_length - 1] == 0 && dst_length > 0)
+ while (dst_length > 0 && ptr[dst_length - 1] == 0)
dst_length--;
bit_length = !dst_length ? 0
: (8 * dst_length -
hx->intra_gb_ptr =
hx->inter_gb_ptr = NULL;
- if ((err = decode_slice_header(hx, h)) < 0)
+ if ((err = decode_slice_header(hx, h)) < 0) {
+ /* make sure data_partitioning is cleared if it was set
+ * before, so we don't try decoding a slice without a valid
+ * slice header later */
+ h->data_partitioning = 0;
break;
+ }
hx->data_partitioning = 1;
break;
return 0;
}
-static int decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *avpkt)
+static int h264_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
}
}
- assert(pict->data[0] || !*got_frame);
+ assert(pict->buf[0] || !*got_frame);
return get_consumed_bytes(buf_index, buf_size);
}
.priv_data_size = sizeof(H264Context),
.init = ff_h264_decode_init,
.close = h264_decode_end,
- .decode = decode_frame,
+ .decode = h264_decode_frame,
.capabilities = /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 |
CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS |
CODEC_CAP_FRAME_THREADS,