[FFmpeg-devel] [PATCH] h264.c: add HW acceleration hooks
Michael Niedermayer
michaelni
Wed Feb 25 20:43:19 CET 2009
On Wed, Feb 25, 2009 at 05:52:56PM +0100, Gwenole Beauchesne wrote:
> Hi,
>
> This patch adds HW acceleration hooks to the H.264 codec.
>
> Regards,
> Gwenole.
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 344cee5..b1ee0e4 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -4034,6 +4034,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
> slice_group_change_cycle= get_bits(&s->gb, ?);
> #endif
>
> + if (s->avctx->hwaccel && h0->current_slice == 0) {
> + if (s->avctx->hwaccel->start_frame(s->avctx, NULL, 0) < 0)
> + return -1;
> + }
> +
> h0->last_slice_type = slice_type;
> h->slice_num = ++h0->current_slice;
> if(h->slice_num >= MAX_SLICES){
outside of decode_slice_header() seems a nicer place ...
> @@ -7494,6 +7499,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
> && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos!=FF_B_TYPE)
> && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==FF_I_TYPE)
> && avctx->skip_frame < AVDISCARD_ALL){
> + if(avctx->hwaccel) {
> + if (avctx->hwaccel->decode_slice(avctx, &buf[buf_index - consumed], consumed) < 0)
> + return -1;
> + }else
> if(CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
> static const uint8_t start_code[] = {0x00, 0x00, 0x01};
> ff_vdpau_add_data_chunk(s, start_code, sizeof(start_code));
applied
> @@ -7558,7 +7567,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
> av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", h->nal_unit_type, bit_length);
> }
>
> - if(context_count == h->max_contexts) {
> + if(avctx->hwaccel){
> + /* Make sure we never call execute_decode_slices() */
> + context_count = 0;
> + }else if(context_count == h->max_contexts) {
> execute_decode_slices(h, context_count);
> context_count = 0;
> }
considering the if(avctx->hwaccel) in execute_decode_slices()
this code and comment seems not entirely ideal
> @@ -7706,6 +7718,11 @@ static int decode_frame(AVCodecContext *avctx,
> h->prev_frame_num_offset= h->frame_num_offset;
> h->prev_frame_num= h->frame_num;
>
> + if (avctx->hwaccel) {
> + if (avctx->hwaccel->end_frame(avctx) < 0)
> + return -1;
> + }
> +
> if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
> ff_vdpau_h264_picture_complete(s);
>
this seems the only code that does a return -1 there ...
what is the intent of that? besides what is the meaning of
end_frame() failing?
if there is none then its return type should be void
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090225/81784bde/attachment.pgp>
More information about the ffmpeg-devel
mailing list