diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 1a126be..7cbd798 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1145,7 +1145,9 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
         blkoff = ((i & 1) << 2) + ((i & 4) << 3);
         if(cbp & 1)
             rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0);
+        //{START_TIMER
         r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]);
+        //STOP_TIMER("first")}
         if(r->is16) //FIXME: optimize
             s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)];
         r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
@@ -1157,7 +1159,9 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
         blknum = ((i & 4) >> 2) + 4;
         blkoff = ((i & 1) << 2) + ((i & 2) << 4);
         rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1);
+        //{START_TIMER
         r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]);
+        //STOP_TIMER("second")}
         r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
     }
     if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c
index 974bf9e..302cb17 100644
--- a/libavcodec/rv34dsp.c
+++ b/libavcodec/rv34dsp.c
@@ -122,4 +122,8 @@ av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
 
     if (HAVE_NEON)
         ff_rv34dsp_init_neon(c, dsp);
+#ifdef HAVE_YASM
+    if (HAVE_MMX)
+        ff_rv34dsp_init_x86(c, dsp);
+#endif
 }
diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h
index 01352ea..b4de5f3 100644
--- a/libavcodec/rv34dsp.h
+++ b/libavcodec/rv34dsp.h
@@ -67,6 +67,7 @@ void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp);
 void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp);
 
 void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext *dsp);
+void ff_rv34dsp_init_x86(RV34DSPContext *c, DSPContext *dsp);
 
 void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp);
 void ff_rv40dsp_init_neon(RV34DSPContext *c, DSPContext *dsp);
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index aa97942..40b3457 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -24,7 +24,11 @@ YASM-OBJS-$(CONFIG_H264PRED)           += x86/h264_intrapred.o          \
                                           x86/h264_intrapred_10bit.o
 MMX-OBJS-$(CONFIG_H264PRED)            += x86/h264_intrapred_init.o
 
-MMX-OBJS-$(CONFIG_RV40_DECODER)        += x86/rv40dsp.o                 \
+YASM-OBJS-$(CONFIG_RV30_DECODER)       += x86/rv34dsp_init.o            \
+                                          x86/rv34dsp.o                                          
+MMX-OBJS-$(CONFIG_RV40_DECODER)        += x86/rv40dsp.o
+YASM-OBJS-$(CONFIG_RV40_DECODER)       += x86/rv34dsp_init.o            \
+                                          x86/rv34dsp.o                                          
 
 YASM-OBJS-$(CONFIG_VC1_DECODER)        += x86/vc1dsp_yasm.o
 
diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm
new file mode 100644
index 0000000..7d51a55
--- /dev/null
+++ b/libavcodec/x86/rv34dsp.asm
@@ -0,0 +1,114 @@
+;******************************************************************************
+;* MMX/SSE2-optimized functions for the RV30 and RV40 decoders
+;* Copyright (C) 2012 <christophe.gisquet@gmail.com>
+;*
+;* This file is part of Libav.
+;*
+;* Libav is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* Libav is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with Libav; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION .text
+
+cextern pw_8
+
+%macro RV34DQ_MMX2 3
+  movq          m2, [%1+ 0]
+  movq          m3, [%1+16]
+  movq          m4, [%1+32]
+  movq          m5, [%1+48]
+  pmullw        m2, %2
+  pmullw        m3, %3
+  pmullw        m4, %3
+  pmullw        m5, %3
+  paddw         m2, m1
+  paddw         m3, m1
+  paddw         m4, m1
+  paddw         m5, m1
+  psraw         m2, 4
+  psraw         m3, 4
+  psraw         m4, 4
+  psraw         m5, 4
+  movq          [%1+ 0], m2
+  movq          [%1+16], m3
+  movq          [%1+32], m4
+  movq          [%1+48], m5
+%endmacro
+
+%macro RV34DQ_SSE2 3
+  movq          m2, [%1+ 0]
+  movq          m4, [%1+16]
+  movq          m3, [%1+32]
+  movq          m5, [%1+48]
+  punpcklqdq    m2, m4
+  punpcklqdq    m3, m5
+  pmullw        m2, %2
+  pmullw        m3, %3
+  paddw         m2, [pw_8]
+  paddw         m3, [pw_8]
+  psraw         m2, 4
+  psraw         m3, 4
+%if 1
+  pshufd        m4, m2, 1110b
+  pshufd        m5, m3, 1110b
+  movq          [%1+ 0], m2
+  movq          [%1+16], m4
+  movq          [%1+32], m3
+  movq          [%1+48], m5
+%else ; no speed difference
+  movq          [%1+ 0], m2
+  movq          [%1+32], m3
+  punpckhqdq    m2, m2
+  punpckhqdq    m3, m3
+  movq          [%1+16], m2
+  movq          [%1+48], m3
+%endif
+%endmacro
+
+%macro ff_rv34_dequant4x4 2
+; void ff_rv34_dequant4x4_<opt>(DCTELEM *block, int Qdc, int Q)
+; We do not need to load Qdc and Q into gprs
+cglobal rv34_dequant4x4_%1, 1, 1, %2
+%ifdef ARCH_X86_64
+    movu    m7, [rsp+16]
+    ; int is 64 bits: m7 = 0 0 0 Q 0 0 0 Qdc
+    ; TODO
+%else
+    movq    m7, [rsp+ 8]
+    ; int is 32bits: m7 = X X X X 0 Q 0 Qdc
+%ifidn %1, sse2
+    pshuflw m7, m7, 10101000b  ; m7 = XXXX Q Q Q Qdc
+    pshufd  m0, m7, 01010101b  ; QQ QQ QQ QQ
+    pshufd  m7, m7, 01010100b  ; QQ QQ QQ QQdc
+%else
+    pshufw  m0, m7, 10101010b  ; Q Q Q Q
+    movq    m1, [pw_8]
+    pshufw  m7, m7, 10101000b  ; Q Q Q Qdc
+%endif
+%endif
+
+    RV34DQ  r0, m7, m0
+    REP_RET
+%endmacro
+
+INIT_MMX
+%define RV34DQ RV34DQ_MMX2
+ff_rv34_dequant4x4 mmx2, 0
+
+INIT_XMM
+%define RV34DQ RV34DQ_SSE2
+ff_rv34_dequant4x4 sse2, 6
diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c
new file mode 100644
index 0000000..2d4f8f3
--- /dev/null
+++ b/libavcodec/x86/rv34dsp_init.c
@@ -0,0 +1,43 @@
+/*
+ * RV30/40 MMX/SSE2 optimizations
+ * Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/cpu.h"
+#include "libavutil/x86_cpu.h"
+#include "libavcodec/dsputil.h"
+#include "libavcodec/rv34dsp.h"
+
+void ff_rv34_dequant4x4_mmx2(DCTELEM *block, int Qdc, int Q);
+void ff_rv34_dequant4x4_sse2(DCTELEM *block, int Qdc, int Q);
+
+av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
+{
+#if HAVE_YASM
+    int mm_flags = av_get_cpu_flags();
+
+    if (mm_flags & AV_CPU_FLAG_MMX2) {
+        c->rv34_dequant4x4 = ff_rv34_dequant4x4_mmx2;
+    }
+
+    if (mm_flags & AV_CPU_FLAG_SSE2) {
+        c->rv34_dequant4x4 = ff_rv34_dequant4x4_sse2;
+    }
+#endif
+}
