annotate ffmpeg/libavcodec/vdpau_mpeg4.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * MPEG-4 Part 2 / H.263 decode acceleration through VDPAU
yading@10 3 *
yading@10 4 * Copyright (c) 2008 NVIDIA
yading@10 5 * Copyright (c) 2013 Rémi Denis-Courmont
yading@10 6 *
yading@10 7 * This file is part of FFmpeg.
yading@10 8 *
yading@10 9 * FFmpeg is free software; you can redistribute it and/or
yading@10 10 * modify it under the terms of the GNU Lesser General Public
yading@10 11 * License as published by the Free Software Foundation; either
yading@10 12 * version 2.1 of the License, or (at your option) any later version.
yading@10 13 *
yading@10 14 * FFmpeg is distributed in the hope that it will be useful,
yading@10 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 17 * Lesser General Public License for more details.
yading@10 18 *
yading@10 19 * You should have received a copy of the GNU Lesser General Public
yading@10 20 * License along with FFmpeg; if not, write to the Free Software Foundation,
yading@10 21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 22 */
yading@10 23
yading@10 24 #include <vdpau/vdpau.h>
yading@10 25
yading@10 26 #include "avcodec.h"
yading@10 27 #include "vdpau.h"
yading@10 28 #include "vdpau_internal.h"
yading@10 29
yading@10 30 static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
yading@10 31 const uint8_t *buffer, uint32_t size)
yading@10 32 {
yading@10 33 MpegEncContext * const s = avctx->priv_data;
yading@10 34 AVVDPAUContext *hwctx = avctx->hwaccel_context;
yading@10 35 VdpPictureInfoMPEG4Part2 *info = &hwctx->info.mpeg4;
yading@10 36 VdpVideoSurface ref;
yading@10 37 int i;
yading@10 38
yading@10 39 /* fill VdpPictureInfoMPEG4Part2 struct */
yading@10 40 info->forward_reference = VDP_INVALID_HANDLE;
yading@10 41 info->backward_reference = VDP_INVALID_HANDLE;
yading@10 42 info->vop_coding_type = 0;
yading@10 43
yading@10 44 switch (s->pict_type) {
yading@10 45 case AV_PICTURE_TYPE_B:
yading@10 46 ref = ff_vdpau_get_surface_id(&s->next_picture);
yading@10 47 assert(ref != VDP_INVALID_HANDLE);
yading@10 48 info->backward_reference = ref;
yading@10 49 info->vop_coding_type = 2;
yading@10 50 /* fall-through */
yading@10 51 case AV_PICTURE_TYPE_P:
yading@10 52 ref = ff_vdpau_get_surface_id(&s->last_picture);
yading@10 53 assert(ref != VDP_INVALID_HANDLE);
yading@10 54 info->forward_reference = ref;
yading@10 55 }
yading@10 56
yading@10 57 info->trd[0] = s->pp_time;
yading@10 58 info->trb[0] = s->pb_time;
yading@10 59 info->trd[1] = s->pp_field_time >> 1;
yading@10 60 info->trb[1] = s->pb_field_time >> 1;
yading@10 61 info->vop_time_increment_resolution = s->avctx->time_base.den;
yading@10 62 info->vop_fcode_forward = s->f_code;
yading@10 63 info->vop_fcode_backward = s->b_code;
yading@10 64 info->resync_marker_disable = !s->resync_marker;
yading@10 65 info->interlaced = !s->progressive_sequence;
yading@10 66 info->quant_type = s->mpeg_quant;
yading@10 67 info->quarter_sample = s->quarter_sample;
yading@10 68 info->short_video_header = avctx->codec->id == AV_CODEC_ID_H263;
yading@10 69 info->rounding_control = s->no_rounding;
yading@10 70 info->alternate_vertical_scan_flag = s->alternate_scan;
yading@10 71 info->top_field_first = s->top_field_first;
yading@10 72 for (i = 0; i < 64; ++i) {
yading@10 73 info->intra_quantizer_matrix[i] = s->intra_matrix[i];
yading@10 74 info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
yading@10 75 }
yading@10 76
yading@10 77 ff_vdpau_common_start_frame(avctx, buffer, size);
yading@10 78 return ff_vdpau_add_buffer(avctx, buffer, size);
yading@10 79 }
yading@10 80
yading@10 81 static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx,
yading@10 82 av_unused const uint8_t *buffer,
yading@10 83 av_unused uint32_t size)
yading@10 84 {
yading@10 85 return 0;
yading@10 86 }
yading@10 87
yading@10 88 #if CONFIG_H263_VDPAU_HWACCEL
yading@10 89 AVHWAccel ff_h263_vdpau_hwaccel = {
yading@10 90 .name = "h263_vdpau",
yading@10 91 .type = AVMEDIA_TYPE_VIDEO,
yading@10 92 .id = AV_CODEC_ID_H263,
yading@10 93 .pix_fmt = AV_PIX_FMT_VDPAU,
yading@10 94 .start_frame = vdpau_mpeg4_start_frame,
yading@10 95 .end_frame = ff_vdpau_mpeg_end_frame,
yading@10 96 .decode_slice = vdpau_mpeg4_decode_slice,
yading@10 97 };
yading@10 98 #endif
yading@10 99
yading@10 100 #if CONFIG_MPEG4_VDPAU_HWACCEL
yading@10 101 AVHWAccel ff_mpeg4_vdpau_hwaccel = {
yading@10 102 .name = "mpeg4_vdpau",
yading@10 103 .type = AVMEDIA_TYPE_VIDEO,
yading@10 104 .id = AV_CODEC_ID_MPEG4,
yading@10 105 .pix_fmt = AV_PIX_FMT_VDPAU,
yading@10 106 .start_frame = vdpau_mpeg4_start_frame,
yading@10 107 .end_frame = ff_vdpau_mpeg_end_frame,
yading@10 108 .decode_slice = vdpau_mpeg4_decode_slice,
yading@10 109 };
yading@10 110 #endif