2 * Copyright 2013 Ilia Mirkin
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include "vl/vl_decoder.h"
27 #include "vl/vl_video_buffer.h"
28 #include "vl/vl_types.h"
30 #include "vl/vl_mpeg12_bitstream.h"
32 #include "util/u_video.h"
34 #include "nv50/nv50_context.h"
36 /* These are expected to be on their own pushbufs */
37 #define SUBC_BSP(m) 2, (m)
38 #define SUBC_VP(m) 2, (m)
41 struct pipe_picture_desc
*base
;
42 struct pipe_mpeg12_picture_desc
*mpeg12
;
43 struct pipe_mpeg4_picture_desc
*mpeg4
;
44 struct pipe_vc1_picture_desc
*vc1
;
45 struct pipe_h264_picture_desc
*h264
;
48 struct nv84_video_buffer
{
49 struct pipe_video_buffer base
;
50 struct pipe_resource
*resources
[VL_NUM_COMPONENTS
];
51 struct pipe_sampler_view
*sampler_view_planes
[VL_NUM_COMPONENTS
];
52 struct pipe_sampler_view
*sampler_view_components
[VL_NUM_COMPONENTS
];
53 struct pipe_surface
*surfaces
[VL_NUM_COMPONENTS
* 2];
55 struct nouveau_bo
*interlaced
, *full
;
57 unsigned frame_num
, frame_num_max
;
61 struct pipe_video_codec base
;
62 struct nouveau_client
*client
;
63 struct nouveau_object
*bsp_channel
, *vp_channel
, *bsp
, *vp
;
64 struct nouveau_pushbuf
*bsp_pushbuf
, *vp_pushbuf
;
65 struct nouveau_bufctx
*bsp_bufctx
, *vp_bufctx
;
67 struct nouveau_bo
*bsp_fw
, *bsp_data
;
68 struct nouveau_bo
*vp_fw
, *vp_data
;
69 struct nouveau_bo
*mbring
, *vpring
;
74 * 1: vpring/mbring cleared, bsp is ready
75 * 2: bsp is done, vp is ready
76 * and then vp it back to 1
78 struct nouveau_bo
*fence
;
80 struct nouveau_bo
*bitstream
;
81 struct nouveau_bo
*vp_params
;
85 unsigned frame_mbs
, frame_size
;
92 unsigned vpring_deblock
, vpring_residual
, vpring_ctrl
;
95 struct vl_mpg12_bs
*mpeg12_bs
;
97 struct nouveau_bo
*mpeg12_bo
;
99 uint16_t *mpeg12_data
;
101 uint8_t mpeg12_intra_matrix
[64];
102 uint8_t mpeg12_non_intra_matrix
[64];
105 static INLINE
uint32_t mb(uint32_t coord
)
107 return (coord
+ 0xf)>>4;
110 static INLINE
uint32_t mb_half(uint32_t coord
)
112 return (coord
+ 0x1f)>>5;
116 nv84_decoder_bsp(struct nv84_decoder
*dec
,
117 struct pipe_h264_picture_desc
*desc
,
118 unsigned num_buffers
,
119 const void *const *data
,
120 const unsigned *num_bytes
,
121 struct nv84_video_buffer
*dest
);
124 nv84_decoder_vp_h264(struct nv84_decoder
*dec
,
125 struct pipe_h264_picture_desc
*desc
,
126 struct nv84_video_buffer
*dest
);
129 nv84_decoder_vp_mpeg12_mb(struct nv84_decoder
*dec
,
130 struct pipe_mpeg12_picture_desc
*desc
,
131 const struct pipe_mpeg12_macroblock
*mb
);
134 nv84_decoder_vp_mpeg12(struct nv84_decoder
*dec
,
135 struct pipe_mpeg12_picture_desc
*desc
,
136 struct nv84_video_buffer
*dest
);