On Wed, Jul 31, 2013 at 09:46:47AM +0200, Vittorio Giovara wrote:
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -1626,11 +1633,16 @@ static int
> decode_update_thread_context(AVCodecContext *dst,
> - if (ff_h264_alloc_tables(h) < 0) {
> + ret = ff_h264_alloc_tables(h);
> + if (ret < 0) {
> av_log(dst, AV_LOG_ERROR, "Could not allocate memory for
> h264\n");
> - return AVERROR(ENOMEM);
> + return ret;
> + }
> + ret = context_init(h);
> + if (ret < 0) {
> + av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
> + return ret;
> }
> - context_init(h);
context_init() was not return-checked before. It's probably a good idea
to change that, but it does not quite fit the log message.
> @@ -4261,38 +4279,42 @@ static int decode_slice(struct AVCodecContext *avctx,
> void *arg)
>
> - if (get_bits_left(&h->gb) == 0) {
> + ret = get_bits_left(&h->gb);
> + if (!ret) {
> er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
> h->mb_x - 1, h->mb_y,
> ER_MB_END);
>
> - return 0;
> + return ret;
Careful, was this unconditionally returning 0 on purpose, or was
that a bug?
> - if (get_bits_left(&h->gb) <= 0 && h->mb_skip_run <= 0) {
> - tprintf(h->avctx, "slice end %d %d\n",
> - get_bits_count(&h->gb), h->gb.size_in_bits);
> - if (get_bits_left(&h->gb) == 0) {
> + ret = get_bits_left(&h->gb);
> + if (ret <= 0 && h->mb_skip_run <= 0) {
> + ret = get_bits_count(&h->gb);
> + tprintf(h->avctx, "slice end %d %d\n", ret,
> h->gb.size_in_bits);
> +
> + ret = get_bits_left(&h->gb);
> + if (!ret) {
> er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
> h->mb_x - 1, h->mb_y,
> ER_MB_END);
> if (h->mb_x > lf_x_start)
> loop_filter(h, lf_x_start, h->mb_x);
>
> - return 0;
> + return ret;
same
> @@ -4351,6 +4373,7 @@ static int decode_nal_units(H264Context *h, const
> uint8_t *buf, int buf_size,
> int pass = !(avctx->active_thread_type & FF_THREAD_FRAME);
> int nals_needed = 0; ///< number of NALs that need decoding before the
> next frame thread starts
> int nal_index;
> + int ret = 0;
>
> h->max_contexts = h->slice_context_count;
> if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {
> @@ -4452,7 +4475,8 @@ static int decode_nal_units(H264Context *h, const
> uint8_t *buf, int buf_size,
> case NAL_IDR_SLICE:
> case NAL_SLICE:
> init_get_bits(&hx->gb, ptr, bit_length);
> - if (!get_ue_golomb(&hx->gb))
> + ret = get_ue_golomb(&hx->gb);
> + if (!ret)
> nals_needed = nal_index;
> }
Pointless, you're not reusing ret.
> @@ -4409,7 +4432,7 @@ static int decode_nal_units(H264Context *h, const
> uint8_t *buf, int buf_size,
> ptr = ff_h264_decode_nal(hx, buf + buf_index, &dst_length,
> &consumed, next_avc - buf_index);
> if (ptr == NULL || dst_length < 0) {
> - buf_index = -1;
> + ret = -1;
> goto end;
> }
> i = buf_index + consumed;
> @@ -4480,7 +4504,7 @@ again:
> if (h->nal_unit_type != NAL_IDR_SLICE) {
> av_log(h->avctx, AV_LOG_ERROR,
> "Invalid mix of idr and non-idr slices\n");
> - buf_index = -1;
> + ret = -1;
> goto end;
> }
> idr(h); // FIXME ensure we don't lose some frames if there
> is reordering
> @@ -4579,10 +4604,10 @@ again:
> - if (h264_set_parameter_from_sps(h) < 0) {
> - buf_index = -1;
> + ret = h264_set_parameter_from_sps(h);
> + if (ret < 0)
> goto end;
> - }
> +
> break;
> case NAL_PPS:
> init_get_bits(&h->gb, ptr, bit_length);
> @@ -4631,7 +4656,7 @@ end:
> h->picture_structure == PICT_BOTTOM_FIELD);
> }
>
> - return buf_index;
> + return (ret < 0) ? ret : buf_index;
> }
This was simpler before when buf_index was returned.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel