| 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_video_buffer.h" |
| 27 |
#include "vl/vl_types.h" |
| 28 |
|
| 29 |
#include "vl/vl_mpeg12_bitstream.h" |
| 30 |
|
| 31 |
#include "util/u_video.h" |
| 32 |
|
| 33 |
#include "nv50/nv50_context.h" |
| 34 |
|
| 35 |
/* These are expected to be on their own pushbufs */ |
| 36 |
#define SUBC_BSP(m) 2, (m) |
| 37 |
#define SUBC_VP(m) 2, (m) |
| 38 |
|
| 39 |
union pipe_desc { |
| 40 |
struct pipe_picture_desc *base; |
| 41 |
struct pipe_mpeg12_picture_desc *mpeg12; |
| 42 |
struct pipe_vc1_picture_desc *vc1; |
| 43 |
struct pipe_h264_picture_desc *h264; |
| 44 |
}; |
| 45 |
|
| 46 |
struct nv84_video_buffer { |
| 47 |
struct pipe_video_buffer base; |
| 48 |
struct pipe_resource *resources[VL_NUM_COMPONENTS]; |
| 49 |
struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS]; |
| 50 |
struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS]; |
| 51 |
struct pipe_surface surfaces[VL_NUM_COMPONENTS * 2]; |
| 52 |
|
| 53 |
struct nouveau_bo *interlaced, *full; |
| 54 |
int mvidx; |
| 55 |
unsigned frame_num, frame_num_max; |
| 56 |
}; |
| 57 |
|
| 58 |
struct nv84_decoder { |
| 59 |
struct pipe_video_codec base; |
| 60 |
struct nouveau_client *client; |
| 61 |
struct nouveau_object *bsp_channel, *vp_channel, *bsp, *vp; |
| 62 |
struct nouveau_pushbuf *bsp_pushbuf, *vp_pushbuf; |
| 63 |
struct nouveau_bufctx *bsp_bufctx, *vp_bufctx; |
| 64 |
|
| 65 |
struct nouveau_bo *bsp_fw, *bsp_data; |
| 66 |
struct nouveau_bo *vp_fw, *vp_data; |
| 67 |
struct nouveau_bo *mbring, *vpring; |
| 68 |
|
| 69 |
/* |
| 70 |
* states: |
| 71 |
* 0: init |
| 72 |
* 1: vpring/mbring cleared, bsp is ready |
| 73 |
* 2: bsp is done, vp is ready |
| 74 |
* and then vp it back to 1 |
| 75 |
*/ |
| 76 |
struct nouveau_bo *fence; |
| 77 |
|
| 78 |
struct nouveau_bo *bitstream; |
| 79 |
struct nouveau_bo *vp_params; |
| 80 |
|
| 81 |
size_t vp_fw2_offset; |
| 82 |
|
| 83 |
unsigned frame_mbs, frame_size; |
| 84 |
/* VPRING layout: |
| 85 |
RESIDUAL |
| 86 |
CTRL |
| 87 |
DEBLOCK |
| 88 |
0x1000 |
| 89 |
*/ |
| 90 |
unsigned vpring_deblock, vpring_residual, vpring_ctrl; |
| 91 |
|
| 92 |
|
| 93 |
struct vl_mpg12_bs *mpeg12_bs; |
| 94 |
|
| 95 |
struct nouveau_bo *mpeg12_bo; |
| 96 |
void *mpeg12_mb_info; |
| 97 |
uint16_t *mpeg12_data; |
| 98 |
const int *zscan; |
| 99 |
uint8_t mpeg12_intra_matrix[64]; |
| 100 |
uint8_t mpeg12_non_intra_matrix[64]; |
| 101 |
}; |
| 102 |
|
| 103 |
static inline uint32_t mb(uint32_t coord) |
| 104 |
{ |
| 105 |
return (coord + 0xf)>>4; |
| 106 |
} |
| 107 |
|
| 108 |
static inline uint32_t mb_half(uint32_t coord) |
| 109 |
{ |
| 110 |
return (coord + 0x1f)>>5; |
| 111 |
} |
| 112 |
|
| 113 |
int |
| 114 |
nv84_decoder_bsp(struct nv84_decoder *dec, |
| 115 |
struct pipe_h264_picture_desc *desc, |
| 116 |
unsigned num_buffers, |
| 117 |
const void *const *data, |
| 118 |
const unsigned *num_bytes, |
| 119 |
struct nv84_video_buffer *dest); |
| 120 |
|
| 121 |
void |
| 122 |
nv84_decoder_vp_h264(struct nv84_decoder *dec, |
| 123 |
struct pipe_h264_picture_desc *desc, |
| 124 |
struct nv84_video_buffer *dest); |
| 125 |
|
| 126 |
void |
| 127 |
nv84_decoder_vp_mpeg12_mb(struct nv84_decoder *dec, |
| 128 |
struct pipe_mpeg12_picture_desc *desc, |
| 129 |
const struct pipe_mpeg12_macroblock *mb); |
| 130 |
|
| 131 |
void |
| 132 |
nv84_decoder_vp_mpeg12(struct nv84_decoder *dec, |
| 133 |
struct pipe_mpeg12_picture_desc *desc, |
| 134 |
struct nv84_video_buffer *dest); |
| 135 |
|
| 136 |
#endif |