summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-02-07 21:04:32 +0100
committerDiego Biurrun <diego@biurrun.de>2013-02-07 22:05:25 +0100
commit0b016eb99d38738e2c53e36549a4732a0f863b2e (patch)
tree2402133365339f6e203b1c21da89363e49d9cf40 /libavcodec/mpegvideo.c
parenta1d36730342edf7281e5992a7f8aafabc2464ed0 (diff)
dsputil: Move ff_block_permute to mpegvideo_enc
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a64906fd0c..4b68fd56a0 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2499,6 +2499,35 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
}
}
+/**
+ * Permute an 8x8 block.
+ * @param block the block which will be permuted according to the given permutation vector
+ * @param permutation the permutation vector
+ * @param last the last non zero coefficient in scantable order, used to speed the permutation up
+ * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
+ * (inverse) permutated to scantable order!
+ */
+void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
+{
+ int i;
+ int16_t temp[64];
+
+ if(last<=0) return;
+ //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations
+
+ for(i=0; i<=last; i++){
+ const int j= scantable[i];
+ temp[j]= block[j];
+ block[j]=0;
+ }
+
+ for(i=0; i<=last; i++){
+ const int j= scantable[i];
+ const int perm_j= permutation[j];
+ block[perm_j]= temp[j];
+ }
+}
+
void ff_mpeg_flush(AVCodecContext *avctx){
int i;
MpegEncContext *s = avctx->priv_data;