Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | /* |
2 | * Copyright 2013 Ilia Mirkin |
||
3 | * |
||
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
5 | * copy of this software and associated documentation files (the "Software"), |
||
6 | * to deal in the Software without restriction, including without limitation |
||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
8 | * and/or sell copies of the Software, and to permit persons to whom the |
||
9 | * Software is furnished to do so, subject to the following conditions: |
||
10 | * |
||
11 | * The above copyright notice and this permission notice shall be included in |
||
12 | * all copies or substantial portions of the Software. |
||
13 | * |
||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||
20 | * OTHER DEALINGS IN THE SOFTWARE. |
||
21 | */ |
||
22 | |||
23 | #ifndef NV84_VIDEO_H_ |
||
24 | #define NV84_VIDEO_H_ |
||
25 | |||
26 | #include "vl/vl_decoder.h" |
||
27 | #include "vl/vl_video_buffer.h" |
||
28 | #include "vl/vl_types.h" |
||
29 | |||
30 | #include "vl/vl_mpeg12_bitstream.h" |
||
31 | |||
32 | #include "util/u_video.h" |
||
33 | |||
34 | #include "nv50_context.h" |
||
35 | |||
36 | union pipe_desc { |
||
37 | struct pipe_picture_desc *base; |
||
38 | struct pipe_mpeg12_picture_desc *mpeg12; |
||
39 | struct pipe_mpeg4_picture_desc *mpeg4; |
||
40 | struct pipe_vc1_picture_desc *vc1; |
||
41 | struct pipe_h264_picture_desc *h264; |
||
42 | }; |
||
43 | |||
44 | struct nv84_video_buffer { |
||
45 | struct pipe_video_buffer base; |
||
46 | struct pipe_resource *resources[VL_NUM_COMPONENTS]; |
||
47 | struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS]; |
||
48 | struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS]; |
||
49 | struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2]; |
||
50 | |||
51 | struct nouveau_bo *interlaced, *full; |
||
52 | int mvidx; |
||
53 | unsigned frame_num, frame_num_max; |
||
54 | }; |
||
55 | |||
56 | struct nv84_decoder { |
||
57 | struct pipe_video_decoder base; |
||
58 | struct nouveau_client *client; |
||
59 | struct nouveau_object *bsp_channel, *vp_channel, *bsp, *vp; |
||
60 | struct nouveau_pushbuf *bsp_pushbuf, *vp_pushbuf; |
||
61 | struct nouveau_bufctx *bsp_bufctx, *vp_bufctx; |
||
62 | |||
63 | struct nouveau_bo *bsp_fw, *bsp_data; |
||
64 | struct nouveau_bo *vp_fw, *vp_data; |
||
65 | struct nouveau_bo *mbring, *vpring; |
||
66 | |||
67 | /* |
||
68 | * states: |
||
69 | * 0: init |
||
70 | * 1: vpring/mbring cleared, bsp is ready |
||
71 | * 2: bsp is done, vp is ready |
||
72 | * and then vp it back to 1 |
||
73 | */ |
||
74 | struct nouveau_bo *fence; |
||
75 | |||
76 | struct nouveau_bo *bitstream; |
||
77 | struct nouveau_bo *vp_params; |
||
78 | |||
79 | size_t vp_fw2_offset; |
||
80 | |||
81 | unsigned frame_mbs, frame_size; |
||
82 | /* VPRING layout: |
||
83 | RESIDUAL |
||
84 | CTRL |
||
85 | DEBLOCK |
||
86 | 0x1000 |
||
87 | */ |
||
88 | unsigned vpring_deblock, vpring_residual, vpring_ctrl; |
||
89 | |||
90 | |||
91 | struct vl_mpg12_bs *mpeg12_bs; |
||
92 | |||
93 | struct nouveau_bo *mpeg12_bo; |
||
94 | void *mpeg12_mb_info; |
||
95 | uint16_t *mpeg12_data; |
||
96 | const int *zscan; |
||
97 | uint8_t mpeg12_intra_matrix[64]; |
||
98 | uint8_t mpeg12_non_intra_matrix[64]; |
||
99 | }; |
||
100 | |||
101 | static INLINE uint32_t mb(uint32_t coord) |
||
102 | { |
||
103 | return (coord + 0xf)>>4; |
||
104 | } |
||
105 | |||
106 | static INLINE uint32_t mb_half(uint32_t coord) |
||
107 | { |
||
108 | return (coord + 0x1f)>>5; |
||
109 | } |
||
110 | |||
111 | int |
||
112 | nv84_decoder_bsp(struct nv84_decoder *dec, |
||
113 | struct pipe_h264_picture_desc *desc, |
||
114 | unsigned num_buffers, |
||
115 | const void *const *data, |
||
116 | const unsigned *num_bytes, |
||
117 | struct nv84_video_buffer *dest); |
||
118 | |||
119 | void |
||
120 | nv84_decoder_vp_h264(struct nv84_decoder *dec, |
||
121 | struct pipe_h264_picture_desc *desc, |
||
122 | struct nv84_video_buffer *dest); |
||
123 | |||
124 | void |
||
125 | nv84_decoder_vp_mpeg12_mb(struct nv84_decoder *dec, |
||
126 | struct pipe_mpeg12_picture_desc *desc, |
||
127 | const struct pipe_mpeg12_macroblock *mb); |
||
128 | |||
129 | void |
||
130 | nv84_decoder_vp_mpeg12(struct nv84_decoder *dec, |
||
131 | struct pipe_mpeg12_picture_desc *desc, |
||
132 | struct nv84_video_buffer *dest); |
||
133 | |||
134 | #endif |