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