summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChristian König <[email protected]>2014-04-04 17:14:26 +0200
committerChristian König <[email protected]>2014-04-11 11:35:03 +0200
commit7806dbeb706ac6beb50c29f3c1041700feb9daf0 (patch)
tree9439b2e65048be2b23c115541e59c895d459d698 /src/gallium
parenta56fa0e83b7ba7d2d34179e782abe795a399a001 (diff)
radeon/vce: implement B-frame support
Signed-off-by: Slava Grigorev <[email protected]> Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/radeon/radeon_vce.h2
-rw-r--r--src/gallium/drivers/radeon/radeon_vce_40_2_2.c73
2 files changed, 53 insertions, 22 deletions
diff --git a/src/gallium/drivers/radeon/radeon_vce.h b/src/gallium/drivers/radeon/radeon_vce.h
index f815cad38aa..7cc87be37f3 100644
--- a/src/gallium/drivers/radeon/radeon_vce.h
+++ b/src/gallium/drivers/radeon/radeon_vce.h
@@ -45,7 +45,7 @@
#define RVCE_READWRITE(buf, domain) RVCE_CS(RVCE_RELOC(buf, RADEON_USAGE_READWRITE, domain) * 4)
#define RVCE_END() *begin = (&enc->cs->buf[enc->cs->cdw] - begin) * 4; }
-#define RVCE_NUM_CPB_FRAMES 2
+#define RVCE_NUM_CPB_FRAMES 3
struct r600_common_screen;
diff --git a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
index 1327d64f983..3b67b31fdf8 100644
--- a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
+++ b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
@@ -54,6 +54,11 @@ static struct rvce_cpb_slot *l0_slot(struct rvce_encoder *enc)
return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next, list);
}
+static struct rvce_cpb_slot *l1_slot(struct rvce_encoder *enc)
+{
+ return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next->next, list);
+}
+
static void frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot,
unsigned *luma_offset, unsigned *chroma_offset)
{
@@ -99,8 +104,8 @@ static void create(struct rvce_encoder *enc)
RVCE_BEGIN(0x01000001); // create cmd
RVCE_CS(0x00000000); // encUseCircularBuffer
- RVCE_CS(0x00000041); // encProfile
- RVCE_CS(0x0000000a); // encLevel
+ RVCE_CS(0x0000004d); // encProfile: Main
+ RVCE_CS(0x0000002a); // encLevel: 4.2
RVCE_CS(0x00000000); // encPicStructRestriction
RVCE_CS(enc->base.width); // encImageWidth
RVCE_CS(enc->base.height); // encImageHeight
@@ -175,12 +180,12 @@ static void pic_control(struct rvce_encoder *enc)
RVCE_CS(0x00000000); // encSPSID
RVCE_CS(0x00000000); // encPPSID
RVCE_CS(0x00000040); // encConstraintSetFlags
- RVCE_CS(0x00000000); // encBPicPattern
+ RVCE_CS(MAX2(enc->base.max_references, 1) - 1); // encBPicPattern
RVCE_CS(0x00000000); // weightPredModeBPicture
RVCE_CS(MIN2(enc->base.max_references, 2)); // encNumberOfReferenceFrames
RVCE_CS(enc->base.max_references + 1); // encMaxNumRefFrames
- RVCE_CS(0x00000000); // encNumDefaultActiveRefL0
- RVCE_CS(0x00000000); // encNumDefaultActiveRefL1
+ RVCE_CS(0x00000001); // encNumDefaultActiveRefL0
+ RVCE_CS(0x00000001); // encNumDefaultActiveRefL1
RVCE_CS(0x00000000); // encSliceMode
RVCE_CS(0x00000000); // encMaxSliceSize
RVCE_END();
@@ -275,7 +280,7 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(0x00000000); // encInputPic(Addr|Array)Mode
RVCE_CS(0x00000000); // encInputPicTileConfig
RVCE_CS(enc->pic.picture_type); // encPicType
- RVCE_CS(enc->pic.picture_type == 3); // encIdrFlag
+ RVCE_CS(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR); // encIdrFlag
RVCE_CS(0x00000000); // encIdrPicId
RVCE_CS(0x00000000); // encMGSKeyPic
RVCE_CS(0x00000001); // encReferenceFlag
@@ -283,7 +288,17 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(0x00000000); // num_ref_idx_active_override_flag
RVCE_CS(0x00000000); // num_ref_idx_l0_active_minus1
RVCE_CS(0x00000000); // num_ref_idx_l1_active_minus1
- for (i = 0; i < 4; ++i) {
+
+ i = enc->pic.frame_num - enc->pic.ref_idx_l0;
+ if (i > 1 && enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) {
+ RVCE_CS(0x00000001); // encRefListModificationOp
+ RVCE_CS(i - 1); // encRefListModificationNum
+ } else {
+ RVCE_CS(0x00000000); // encRefListModificationOp
+ RVCE_CS(0x00000000); // encRefListModificationNum
+ }
+
+ for (i = 0; i < 3; ++i) {
RVCE_CS(0x00000000); // encRefListModificationOp
RVCE_CS(0x00000000); // encRefListModificationNum
}
@@ -291,22 +306,14 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(0x00000000); // encDecodedPictureMarkingOp
RVCE_CS(0x00000000); // encDecodedPictureMarkingNum
RVCE_CS(0x00000000); // encDecodedPictureMarkingIdx
- }
- for (i = 0; i < 4; ++i) {
RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingOp
RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingNum
}
+ // encReferencePictureL0[0]
RVCE_CS(0x00000000); // pictureStructure
-
- if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) {
- RVCE_CS(0x00000000); // encPicType
- RVCE_CS(0x00000000); // frameNumber
- RVCE_CS(0x00000000); // pictureOrderCount
- RVCE_CS(0xffffffff); // lumaOffset
- RVCE_CS(0xffffffff); // chromaOffset
- }
- else if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) {
+ if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P ||
+ enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) {
struct rvce_cpb_slot *l0 = l0_slot(enc);
frame_offset(enc, l0, &luma_offset, &chroma_offset);
RVCE_CS(l0->picture_type); // encPicType
@@ -314,16 +321,40 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(l0->pic_order_cnt); // pictureOrderCount
RVCE_CS(luma_offset); // lumaOffset
RVCE_CS(chroma_offset); // chromaOffset
+ } else {
+ RVCE_CS(0x00000000); // encPicType
+ RVCE_CS(0x00000000); // frameNumber
+ RVCE_CS(0x00000000); // pictureOrderCount
+ RVCE_CS(0xffffffff); // lumaOffset
+ RVCE_CS(0xffffffff); // chromaOffset
}
- for (i = 0; i < 2; ++i) {
- RVCE_CS(0x00000000); // pictureStructure
+
+ // encReferencePictureL0[1]
+ RVCE_CS(0x00000000); // pictureStructure
+ RVCE_CS(0x00000000); // encPicType
+ RVCE_CS(0x00000000); // frameNumber
+ RVCE_CS(0x00000000); // pictureOrderCount
+ RVCE_CS(0xffffffff); // lumaOffset
+ RVCE_CS(0xffffffff); // chromaOffset
+
+ // encReferencePictureL1[0]
+ RVCE_CS(0x00000000); // pictureStructure
+ if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) {
+ struct rvce_cpb_slot *l1 = l1_slot(enc);
+ frame_offset(enc, l1, &luma_offset, &chroma_offset);
+ RVCE_CS(l1->picture_type); // encPicType
+ RVCE_CS(l1->frame_num); // frameNumber
+ RVCE_CS(l1->pic_order_cnt); // pictureOrderCount
+ RVCE_CS(luma_offset); // lumaOffset
+ RVCE_CS(chroma_offset); // chromaOffset
+ } else {
RVCE_CS(0x00000000); // encPicType
RVCE_CS(0x00000000); // frameNumber
RVCE_CS(0x00000000); // pictureOrderCount
RVCE_CS(0xffffffff); // lumaOffset
RVCE_CS(0xffffffff); // chromaOffset
}
-
+
frame_offset(enc, current_slot(enc), &luma_offset, &chroma_offset);
RVCE_CS(luma_offset); // encReconstructedLumaOffset
RVCE_CS(chroma_offset); // encReconstructedChromaOffset