On Tue, Jul 26, 2016 at 03:41:52PM +0300, Martin Storsjö wrote: [...] > +static int svc_decode_frame(AVCodecContext *avctx, void *data, > + int *got_frame, AVPacket *avpkt) > +{ > + SVCContext *s = avctx->priv_data; > + SBufferInfo info = { 0 }; > + uint8_t* ptrs[3]; > + int linesize[3]; > + AVFrame *avframe = data; > + int ret; > + DECODING_STATE state; > + > + if ((ret = init_bsf(avctx)) < 0) > + return ret; > + > + if (avpkt->size) { > + AVPacket input_ref = { 0 }; > + if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) { > + ret = av_fifo_realloc2(s->packet_fifo, > + av_fifo_size(s->packet_fifo) + > sizeof(input_ref)); > + if (ret < 0) > + return ret; > + } > + > + ret = av_packet_ref(&input_ref, avpkt); > + if (ret < 0) > + return ret; > + av_fifo_generic_write(s->packet_fifo, &input_ref, sizeof(input_ref), > NULL); > + } > + > + while (!*got_frame) { > + /* prepare the input data -- convert to Annex B if needed */ > + if (s->pkt_filtered.size <= 0) { > + AVPacket input_ref; > + > + /* no more data */ > + if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket)) > + return avpkt->size ? avpkt->size : 0; > + > + av_packet_unref(&s->pkt_filtered); > + > + av_fifo_generic_read(s->packet_fifo, &input_ref, > sizeof(input_ref), NULL); > + ret = av_bsf_send_packet(s->bsf, &input_ref); > + if (ret < 0) { > + av_packet_unref(&input_ref); > + return ret; > + } > + > + ret = av_bsf_receive_packet(s->bsf, &s->pkt_filtered); > + if (ret < 0) > + av_packet_move_ref(&s->pkt_filtered, &input_ref); > + else > + av_packet_unref(&input_ref); > + } > + > + state = (*s->decoder)->DecodeFrame2(s->decoder, > s->pkt_filtered.data, s->pkt_filtered.size, ptrs, &info); > + s->pkt_filtered.size = 0; > + if (state != dsErrorFree) { > + av_log(avctx, AV_LOG_ERROR, "DecodeFrame2 failed\n"); > + return AVERROR_UNKNOWN; > + } > + if (info.iBufferStatus != 1) { > + av_log(avctx, AV_LOG_DEBUG, "No frame produced\n"); > + continue; > + } > +
> + ff_set_dimensions(avctx, info.UsrData.sSystemBuffer.iWidth, > info.UsrData.sSystemBuffer.iHeight); The return code should be checked (its checked in all other cases in our codebase except some "0,0" calls IIRC) > + // The decoder doesn't (currently) support decoding into a user > + // provided buffer, so do a copy instead. > + if (ff_get_buffer(avctx, avframe, 0) < 0) { > + av_log(avctx, AV_LOG_ERROR, "Unable to allocate buffer\n"); > + return AVERROR(ENOMEM); > + } > + > + linesize[0] = info.UsrData.sSystemBuffer.iStride[0]; > + linesize[1] = linesize[2] = info.UsrData.sSystemBuffer.iStride[1]; > + av_image_copy(avframe->data, avframe->linesize, (const uint8_t **) > ptrs, linesize, avctx->pix_fmt, avctx->width, avctx->height); > + > + avframe->pts = s->pkt_filtered.pts; > + avframe->pkt_dts = s->pkt_filtered.dts; > +#if FF_API_PKT_PTS > +FF_DISABLE_DEPRECATION_WARNINGS > + avframe->pkt_pts = s->pkt_filtered.pts; > +FF_ENABLE_DEPRECATION_WARNINGS > +#endif this produces a warning: libavcodec/libopenh264dec.c:222:5: warning: "FF_API_PKT_PTS" is not defined [-Wundef] thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel