Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2013 Advanced Micro Devices, Inc.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. /*
  29.  * Authors:
  30.  *      Christian König <christian.koenig@amd.com>
  31.  *
  32.  */
  33.  
  34. #include <stdio.h>
  35.  
  36. #include "pipe/p_video_codec.h"
  37.  
  38. #include "util/u_video.h"
  39. #include "util/u_memory.h"
  40.  
  41. #include "vl/vl_video_buffer.h"
  42.  
  43. #include "r600_pipe_common.h"
  44. #include "radeon_video.h"
  45. #include "radeon_vce.h"
  46.  
  47. static const unsigned profiles[7] = { 66, 77, 88, 100, 110, 122, 244 };
  48.  
  49. static struct rvce_cpb_slot *current_slot(struct rvce_encoder *enc)
  50. {
  51.         return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.prev, list);
  52. }
  53.  
  54. static struct rvce_cpb_slot *l0_slot(struct rvce_encoder *enc)
  55. {
  56.         return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next, list);
  57. }
  58.  
  59. static struct rvce_cpb_slot *l1_slot(struct rvce_encoder *enc)
  60. {
  61.         return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next->next, list);
  62. }
  63.  
  64. static void frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot,
  65.                          unsigned *luma_offset, unsigned *chroma_offset)
  66. {
  67.         unsigned pitch = align(enc->luma->level[0].pitch_bytes, 128);
  68.         unsigned vpitch = align(enc->luma->npix_y, 16);
  69.         unsigned fsize = pitch * (vpitch + vpitch / 2);
  70.  
  71.         *luma_offset = slot->index * fsize;
  72.         *chroma_offset = *luma_offset + pitch * vpitch;
  73. }
  74.  
  75. static void session(struct rvce_encoder *enc)
  76. {
  77.         RVCE_BEGIN(0x00000001); // session cmd
  78.         RVCE_CS(enc->stream_handle);
  79.         RVCE_END();
  80. }
  81.  
  82. static void task_info(struct rvce_encoder *enc, uint32_t taskOperation)
  83. {
  84.         RVCE_BEGIN(0x00000002); // task info
  85.         RVCE_CS(0xffffffff); // offsetOfNextTaskInfo
  86.         RVCE_CS(taskOperation); // taskOperation
  87.         RVCE_CS(0x00000000); // referencePictureDependency
  88.         RVCE_CS(0x00000000); // collocateFlagDependency
  89.         RVCE_CS(0x00000000); // feedbackIndex
  90.         RVCE_CS(0x00000000); // videoBitstreamRingIndex
  91.         RVCE_END();
  92. }
  93.  
  94. static void feedback(struct rvce_encoder *enc)
  95. {
  96.         RVCE_BEGIN(0x05000005); // feedback buffer
  97.         RVCE_WRITE(enc->fb->res->cs_buf, enc->fb->res->domains); // feedbackRingAddressHi
  98.         RVCE_CS(0x00000000); // feedbackRingAddressLo
  99.         RVCE_CS(0x00000001); // feedbackRingSize
  100.         RVCE_END();
  101. }
  102.  
  103. static void create(struct rvce_encoder *enc)
  104. {
  105.         task_info(enc, 0x00000000);
  106.  
  107.         RVCE_BEGIN(0x01000001); // create cmd
  108.         RVCE_CS(0x00000000); // encUseCircularBuffer
  109.         RVCE_CS(profiles[enc->base.profile -
  110.                 PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE]); // encProfile
  111.         RVCE_CS(enc->base.level); // encLevel
  112.         RVCE_CS(0x00000000); // encPicStructRestriction
  113.         RVCE_CS(enc->base.width); // encImageWidth
  114.         RVCE_CS(enc->base.height); // encImageHeight
  115.         RVCE_CS(enc->luma->level[0].pitch_bytes); // encRefPicLumaPitch
  116.         RVCE_CS(enc->chroma->level[0].pitch_bytes); // encRefPicChromaPitch
  117.         RVCE_CS(align(enc->luma->npix_y, 16) / 8); // encRefYHeightInQw
  118.         RVCE_CS(0x00000000); // encRefPic(Addr|Array)Mode, encPicStructRestriction, disableRDO
  119.         RVCE_END();
  120. }
  121.  
  122. static void rate_control(struct rvce_encoder *enc)
  123. {
  124.         RVCE_BEGIN(0x04000005); // rate control
  125.         RVCE_CS(enc->pic.rate_ctrl.rate_ctrl_method); // encRateControlMethod
  126.         RVCE_CS(enc->pic.rate_ctrl.target_bitrate); // encRateControlTargetBitRate
  127.         RVCE_CS(enc->pic.rate_ctrl.peak_bitrate); // encRateControlPeakBitRate
  128.         RVCE_CS(enc->pic.rate_ctrl.frame_rate_num); // encRateControlFrameRateNum
  129.         RVCE_CS(0x00000000); // encGOPSize
  130.         RVCE_CS(enc->pic.quant_i_frames); // encQP_I
  131.         RVCE_CS(enc->pic.quant_p_frames); // encQP_P
  132.         RVCE_CS(enc->pic.quant_b_frames); // encQP_B
  133.         RVCE_CS(enc->pic.rate_ctrl.vbv_buffer_size); // encVBVBufferSize
  134.         RVCE_CS(enc->pic.rate_ctrl.frame_rate_den); // encRateControlFrameRateDen
  135.         RVCE_CS(0x00000000); // encVBVBufferLevel
  136.         RVCE_CS(0x00000000); // encMaxAUSize
  137.         RVCE_CS(0x00000000); // encQPInitialMode
  138.         RVCE_CS(enc->pic.rate_ctrl.target_bits_picture); // encTargetBitsPerPicture
  139.         RVCE_CS(enc->pic.rate_ctrl.peak_bits_picture_integer); // encPeakBitsPerPictureInteger
  140.         RVCE_CS(enc->pic.rate_ctrl.peak_bits_picture_fraction); // encPeakBitsPerPictureFractional
  141.         RVCE_CS(0x00000000); // encMinQP
  142.         RVCE_CS(0x00000033); // encMaxQP
  143.         RVCE_CS(0x00000000); // encSkipFrameEnable
  144.         RVCE_CS(0x00000000); // encFillerDataEnable
  145.         RVCE_CS(0x00000000); // encEnforceHRD
  146.         RVCE_CS(0x00000000); // encBPicsDeltaQP
  147.         RVCE_CS(0x00000000); // encReferenceBPicsDeltaQP
  148.         RVCE_CS(0x00000000); // encRateControlReInitDisable
  149.         RVCE_END();
  150. }
  151.  
  152. static void config_extension(struct rvce_encoder *enc)
  153. {
  154.         RVCE_BEGIN(0x04000001); // config extension
  155.         RVCE_CS(0x00000003); // encEnablePerfLogging
  156.         RVCE_END();
  157. }
  158.  
  159. static void pic_control(struct rvce_encoder *enc)
  160. {
  161.         unsigned encNumMBsPerSlice;
  162.  
  163.         encNumMBsPerSlice = align(enc->base.width, 16) / 16;
  164.         encNumMBsPerSlice *= align(enc->base.height, 16) / 16;
  165.  
  166.         RVCE_BEGIN(0x04000002); // pic control
  167.         RVCE_CS(0x00000000); // encUseConstrainedIntraPred
  168.         RVCE_CS(0x00000000); // encCABACEnable
  169.         RVCE_CS(0x00000000); // encCABACIDC
  170.         RVCE_CS(0x00000000); // encLoopFilterDisable
  171.         RVCE_CS(0x00000000); // encLFBetaOffset
  172.         RVCE_CS(0x00000000); // encLFAlphaC0Offset
  173.         RVCE_CS(0x00000000); // encCropLeftOffset
  174.         RVCE_CS((align(enc->base.width, 16) - enc->base.width) >> 1); // encCropRightOffset
  175.         RVCE_CS(0x00000000); // encCropTopOffset
  176.         RVCE_CS((align(enc->base.height, 16) - enc->base.height) >> 1); // encCropBottomOffset
  177.         RVCE_CS(encNumMBsPerSlice); // encNumMBsPerSlice
  178.         RVCE_CS(0x00000000); // encIntraRefreshNumMBsPerSlot
  179.         RVCE_CS(0x00000000); // encForceIntraRefresh
  180.         RVCE_CS(0x00000000); // encForceIMBPeriod
  181.         RVCE_CS(0x00000000); // encPicOrderCntType
  182.         RVCE_CS(0x00000000); // log2_max_pic_order_cnt_lsb_minus4
  183.         RVCE_CS(0x00000000); // encSPSID
  184.         RVCE_CS(0x00000000); // encPPSID
  185.         RVCE_CS(0x00000040); // encConstraintSetFlags
  186.         RVCE_CS(MAX2(enc->base.max_references, 1) - 1); // encBPicPattern
  187.         RVCE_CS(0x00000000); // weightPredModeBPicture
  188.         RVCE_CS(MIN2(enc->base.max_references, 2)); // encNumberOfReferenceFrames
  189.         RVCE_CS(enc->base.max_references + 1); // encMaxNumRefFrames
  190.         RVCE_CS(0x00000001); // encNumDefaultActiveRefL0
  191.         RVCE_CS(0x00000001); // encNumDefaultActiveRefL1
  192.         RVCE_CS(0x00000000); // encSliceMode
  193.         RVCE_CS(0x00000000); // encMaxSliceSize
  194.         RVCE_END();
  195. }
  196.  
  197. static void motion_estimation(struct rvce_encoder *enc)
  198. {
  199.         RVCE_BEGIN(0x04000007); // motion estimation
  200.         RVCE_CS(0x00000001); // encIMEDecimationSearch
  201.         RVCE_CS(0x00000001); // motionEstHalfPixel
  202.         RVCE_CS(0x00000000); // motionEstQuarterPixel
  203.         RVCE_CS(0x00000000); // disableFavorPMVPoint
  204.         RVCE_CS(0x00000000); // forceZeroPointCenter
  205.         RVCE_CS(0x00000000); // LSMVert
  206.         RVCE_CS(0x00000010); // encSearchRangeX
  207.         RVCE_CS(0x00000010); // encSearchRangeY
  208.         RVCE_CS(0x00000010); // encSearch1RangeX
  209.         RVCE_CS(0x00000010); // encSearch1RangeY
  210.         RVCE_CS(0x00000000); // disable16x16Frame1
  211.         RVCE_CS(0x00000000); // disableSATD
  212.         RVCE_CS(0x00000000); // enableAMD
  213.         RVCE_CS(0x000000fe); // encDisableSubMode
  214.         RVCE_CS(0x00000000); // encIMESkipX
  215.         RVCE_CS(0x00000000); // encIMESkipY
  216.         RVCE_CS(0x00000000); // encEnImeOverwDisSubm
  217.         RVCE_CS(0x00000000); // encImeOverwDisSubmNo
  218.         RVCE_CS(0x00000001); // encIME2SearchRangeX
  219.         RVCE_CS(0x00000001); // encIME2SearchRangeY
  220.         RVCE_CS(0x00000000); // parallelModeSpeedupEnable
  221.         RVCE_CS(0x00000000); // fme0_encDisableSubMode
  222.         RVCE_CS(0x00000000); // fme1_encDisableSubMode
  223.         RVCE_CS(0x00000000); // imeSWSpeedupEnable
  224.         RVCE_END();
  225. }
  226.  
  227. static void rdo(struct rvce_encoder *enc)
  228. {
  229.         RVCE_BEGIN(0x04000008); // rdo
  230.         RVCE_CS(0x00000000); // encDisableTbePredIFrame
  231.         RVCE_CS(0x00000000); // encDisableTbePredPFrame
  232.         RVCE_CS(0x00000000); // useFmeInterpolY
  233.         RVCE_CS(0x00000000); // useFmeInterpolUV
  234.         RVCE_CS(0x00000000); // useFmeIntrapolY
  235.         RVCE_CS(0x00000000); // useFmeIntrapolUV
  236.         RVCE_CS(0x00000000); // useFmeInterpolY_1
  237.         RVCE_CS(0x00000000); // useFmeInterpolUV_1
  238.         RVCE_CS(0x00000000); // useFmeIntrapolY_1
  239.         RVCE_CS(0x00000000); // useFmeIntrapolUV_1
  240.         RVCE_CS(0x00000000); // enc16x16CostAdj
  241.         RVCE_CS(0x00000000); // encSkipCostAdj
  242.         RVCE_CS(0x00000000); // encForce16x16skip
  243.         RVCE_CS(0x00000000); // encDisableThresholdCalcA
  244.         RVCE_CS(0x00000000); // encLumaCoeffCost
  245.         RVCE_CS(0x00000000); // encLumaMBCoeffCost
  246.         RVCE_CS(0x00000000); // encChromaCoeffCost
  247.         RVCE_END();
  248. }
  249.  
  250. static void vui(struct rvce_encoder *enc)
  251. {
  252.         int i;
  253.  
  254.         RVCE_BEGIN(0x04000009); // vui
  255.         RVCE_CS(0x00000000); //aspectRatioInfoPresentFlag
  256.         RVCE_CS(0x00000000); //aspectRatioInfo.aspectRatioIdc
  257.         RVCE_CS(0x00000000); //aspectRatioInfo.sarWidth
  258.         RVCE_CS(0x00000000); //aspectRatioInfo.sarHeight
  259.         RVCE_CS(0x00000000); //overscanInfoPresentFlag
  260.         RVCE_CS(0x00000000); //overScanInfo.overscanAppropFlag
  261.         RVCE_CS(0x00000000); //videoSignalTypePresentFlag
  262.         RVCE_CS(0x00000005); //videoSignalTypeInfo.videoFormat
  263.         RVCE_CS(0x00000000); //videoSignalTypeInfo.videoFullRangeFlag
  264.         RVCE_CS(0x00000000); //videoSignalTypeInfo.colorDescriptionPresentFlag
  265.         RVCE_CS(0x00000002); //videoSignalTypeInfo.colorPrim
  266.         RVCE_CS(0x00000002); //videoSignalTypeInfo.transferChar
  267.         RVCE_CS(0x00000002); //videoSignalTypeInfo.matrixCoef
  268.         RVCE_CS(0x00000000); //chromaLocInfoPresentFlag
  269.         RVCE_CS(0x00000000); //chromaLocInfo.chromaLocTop
  270.         RVCE_CS(0x00000000); //chromaLocInfo.chromaLocBottom
  271.         RVCE_CS(0x00000001); //timingInfoPresentFlag
  272.         RVCE_CS(enc->pic.rate_ctrl.frame_rate_den); //timingInfo.numUnitsInTick
  273.         RVCE_CS(enc->pic.rate_ctrl.frame_rate_num * 2); //timingInfo.timeScale;
  274.         RVCE_CS(0x00000001); //timingInfo.fixedFrameRateFlag
  275.         RVCE_CS(0x00000000); //nalHRDParametersPresentFlag
  276.         RVCE_CS(0x00000000); //hrdParam.cpbCntMinus1
  277.         RVCE_CS(0x00000004); //hrdParam.bitRateScale
  278.         RVCE_CS(0x00000006); //hrdParam.cpbSizeScale
  279.         for (i = 0; i < 32; i++) {
  280.                 RVCE_CS(0x00000000); //hrdParam.bitRateValueMinus
  281.                 RVCE_CS(0x00000000); //hrdParam.cpbSizeValueMinus
  282.                 RVCE_CS(0x00000000); //hrdParam.cbrFlag
  283.         }
  284.         RVCE_CS(0x00000017); //hrdParam.initialCpbRemovalDelayLengthMinus1
  285.         RVCE_CS(0x00000017); //hrdParam.cpbRemovalDelayLengthMinus1
  286.         RVCE_CS(0x00000017); //hrdParam.dpbOutputDelayLengthMinus1
  287.         RVCE_CS(0x00000018); //hrdParam.timeOffsetLength
  288.         RVCE_CS(0x00000000); //lowDelayHRDFlag
  289.         RVCE_CS(0x00000000); //picStructPresentFlag
  290.         RVCE_CS(0x00000000); //bitstreamRestrictionPresentFlag
  291.         RVCE_CS(0x00000001); //bitstreamRestrictions.motionVectorsOverPicBoundariesFlag
  292.         RVCE_CS(0x00000002); //bitstreamRestrictions.maxBytesPerPicDenom
  293.         RVCE_CS(0x00000001); //bitstreamRestrictions.maxBitsPerMbDenom
  294.         RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthHori
  295.         RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthVert
  296.         RVCE_CS(0x00000003); //bitstreamRestrictions.numReorderFrames
  297.         RVCE_CS(0x00000003); //bitstreamRestrictions.maxDecFrameBuffering
  298.         RVCE_END();
  299. }
  300.  
  301. static void encode(struct rvce_encoder *enc)
  302. {
  303.         int i;
  304.         unsigned luma_offset, chroma_offset;
  305.  
  306.         task_info(enc, 0x00000003);
  307.  
  308.         RVCE_BEGIN(0x05000001); // context buffer
  309.         RVCE_READWRITE(enc->cpb.res->cs_buf, enc->cpb.res->domains); // encodeContextAddressHi
  310.         RVCE_CS(0x00000000); // encodeContextAddressLo
  311.         RVCE_END();
  312.  
  313.         RVCE_BEGIN(0x05000004); // video bitstream buffer
  314.         RVCE_WRITE(enc->bs_handle, RADEON_DOMAIN_GTT); // videoBitstreamRingAddressHi
  315.         RVCE_CS(0x00000000); // videoBitstreamRingAddressLo
  316.         RVCE_CS(enc->bs_size); // videoBitstreamRingSize
  317.         RVCE_END();
  318.  
  319.         RVCE_BEGIN(0x03000001); // encode
  320.         RVCE_CS(0x00000000); // insertHeaders
  321.         RVCE_CS(0x00000000); // pictureStructure
  322.         RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize
  323.         RVCE_CS(0x00000000); // forceRefreshMap
  324.         RVCE_CS(0x00000000); // insertAUD
  325.         RVCE_CS(0x00000000); // endOfSequence
  326.         RVCE_CS(0x00000000); // endOfStream
  327.         RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM); // inputPictureLumaAddressHi
  328.         RVCE_CS(enc->luma->level[0].offset); // inputPictureLumaAddressLo
  329.         RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM); // inputPictureChromaAddressHi
  330.         RVCE_CS(enc->chroma->level[0].offset); // inputPictureChromaAddressLo
  331.         RVCE_CS(align(enc->luma->npix_y, 16)); // encInputFrameYPitch
  332.         RVCE_CS(enc->luma->level[0].pitch_bytes); // encInputPicLumaPitch
  333.         RVCE_CS(enc->chroma->level[0].pitch_bytes); // encInputPicChromaPitch
  334.         RVCE_CS(0x00000000); // encInputPic(Addr|Array)Mode
  335.         RVCE_CS(0x00000000); // encInputPicTileConfig
  336.         RVCE_CS(enc->pic.picture_type); // encPicType
  337.         RVCE_CS(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR); // encIdrFlag
  338.         RVCE_CS(0x00000000); // encIdrPicId
  339.         RVCE_CS(0x00000000); // encMGSKeyPic
  340.         RVCE_CS(!enc->pic.not_referenced); // encReferenceFlag
  341.         RVCE_CS(0x00000000); // encTemporalLayerIndex
  342.         RVCE_CS(0x00000000); // num_ref_idx_active_override_flag
  343.         RVCE_CS(0x00000000); // num_ref_idx_l0_active_minus1
  344.         RVCE_CS(0x00000000); // num_ref_idx_l1_active_minus1
  345.  
  346.         i = enc->pic.frame_num - enc->pic.ref_idx_l0;
  347.         if (i > 1 && enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) {
  348.                 RVCE_CS(0x00000001); // encRefListModificationOp
  349.                 RVCE_CS(i - 1);      // encRefListModificationNum
  350.         } else {
  351.                 RVCE_CS(0x00000000); // encRefListModificationOp
  352.                 RVCE_CS(0x00000000); // encRefListModificationNum
  353.         }
  354.  
  355.         for (i = 0; i < 3; ++i) {
  356.                 RVCE_CS(0x00000000); // encRefListModificationOp
  357.                 RVCE_CS(0x00000000); // encRefListModificationNum
  358.         }
  359.         for (i = 0; i < 4; ++i) {
  360.                 RVCE_CS(0x00000000); // encDecodedPictureMarkingOp
  361.                 RVCE_CS(0x00000000); // encDecodedPictureMarkingNum
  362.                 RVCE_CS(0x00000000); // encDecodedPictureMarkingIdx
  363.                 RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingOp
  364.                 RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingNum
  365.         }
  366.  
  367.         // encReferencePictureL0[0]
  368.         RVCE_CS(0x00000000); // pictureStructure
  369.         if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P ||
  370.            enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) {
  371.                 struct rvce_cpb_slot *l0 = l0_slot(enc);
  372.                 frame_offset(enc, l0, &luma_offset, &chroma_offset);
  373.                 RVCE_CS(l0->picture_type); // encPicType
  374.                 RVCE_CS(l0->frame_num); // frameNumber
  375.                 RVCE_CS(l0->pic_order_cnt); // pictureOrderCount
  376.                 RVCE_CS(luma_offset); // lumaOffset
  377.                 RVCE_CS(chroma_offset); // chromaOffset
  378.         } else {
  379.                 RVCE_CS(0x00000000); // encPicType
  380.                 RVCE_CS(0x00000000); // frameNumber
  381.                 RVCE_CS(0x00000000); // pictureOrderCount
  382.                 RVCE_CS(0xffffffff); // lumaOffset
  383.                 RVCE_CS(0xffffffff); // chromaOffset
  384.         }
  385.  
  386.         // encReferencePictureL0[1]
  387.         RVCE_CS(0x00000000); // pictureStructure
  388.         RVCE_CS(0x00000000); // encPicType
  389.         RVCE_CS(0x00000000); // frameNumber
  390.         RVCE_CS(0x00000000); // pictureOrderCount
  391.         RVCE_CS(0xffffffff); // lumaOffset
  392.         RVCE_CS(0xffffffff); // chromaOffset
  393.  
  394.         // encReferencePictureL1[0]
  395.         RVCE_CS(0x00000000); // pictureStructure
  396.         if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) {
  397.                 struct rvce_cpb_slot *l1 = l1_slot(enc);
  398.                 frame_offset(enc, l1, &luma_offset, &chroma_offset);
  399.                 RVCE_CS(l1->picture_type); // encPicType
  400.                 RVCE_CS(l1->frame_num); // frameNumber
  401.                 RVCE_CS(l1->pic_order_cnt); // pictureOrderCount
  402.                 RVCE_CS(luma_offset); // lumaOffset
  403.                 RVCE_CS(chroma_offset); // chromaOffset
  404.         } else {
  405.                 RVCE_CS(0x00000000); // encPicType
  406.                 RVCE_CS(0x00000000); // frameNumber
  407.                 RVCE_CS(0x00000000); // pictureOrderCount
  408.                 RVCE_CS(0xffffffff); // lumaOffset
  409.                 RVCE_CS(0xffffffff); // chromaOffset
  410.         }
  411.  
  412.         frame_offset(enc, current_slot(enc), &luma_offset, &chroma_offset);
  413.         RVCE_CS(luma_offset); // encReconstructedLumaOffset
  414.         RVCE_CS(chroma_offset); // encReconstructedChromaOffset
  415.         RVCE_CS(0x00000000); // encColocBufferOffset
  416.         RVCE_CS(0x00000000); // encReconstructedRefBasePictureLumaOffset
  417.         RVCE_CS(0x00000000); // encReconstructedRefBasePictureChromaOffset
  418.         RVCE_CS(0x00000000); // encReferenceRefBasePictureLumaOffset
  419.         RVCE_CS(0x00000000); // encReferenceRefBasePictureChromaOffset
  420.         RVCE_CS(0x00000000); // pictureCount
  421.         RVCE_CS(enc->pic.frame_num); // frameNumber
  422.         RVCE_CS(enc->pic.pic_order_cnt); // pictureOrderCount
  423.         RVCE_CS(0x00000000); // numIPicRemainInRCGOP
  424.         RVCE_CS(0x00000000); // numPPicRemainInRCGOP
  425.         RVCE_CS(0x00000000); // numBPicRemainInRCGOP
  426.         RVCE_CS(0x00000000); // numIRPicRemainInRCGOP
  427.         RVCE_CS(0x00000000); // enableIntraRefresh
  428.         RVCE_END();
  429. }
  430.  
  431. static void destroy(struct rvce_encoder *enc)
  432. {
  433.         task_info(enc, 0x00000001);
  434.  
  435.         RVCE_BEGIN(0x02000001); // destroy
  436.         RVCE_END();
  437. }
  438.  
  439. void radeon_vce_40_2_2_init(struct rvce_encoder *enc)
  440. {
  441.         enc->session = session;
  442.         enc->create = create;
  443.         enc->feedback = feedback;
  444.         enc->rate_control = rate_control;
  445.         enc->config_extension = config_extension;
  446.         enc->pic_control = pic_control;
  447.         enc->motion_estimation = motion_estimation;
  448.         enc->rdo = rdo;
  449.         enc->vui = vui;
  450.         enc->encode = encode;
  451.         enc->destroy = destroy;
  452. }
  453.