ffmpeg-cvslog
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
September 2006
- 25 participants
- 267 discussions
02 Sep '06
Author: kostya
Date: Sat Sep 2 06:58:51 2006
New Revision: 6152
Modified:
trunk/libavcodec/dsputil.c
trunk/libavcodec/dsputil.h
trunk/libavcodec/vc1dsp.c
Log:
Drop put_vc1_qpel_pixels_tab as they won't be needed anymore.
Modified: trunk/libavcodec/dsputil.c
==============================================================================
--- trunk/libavcodec/dsputil.c (original)
+++ trunk/libavcodec/dsputil.c Sat Sep 2 06:58:51 2006
@@ -2622,10 +2622,6 @@
void ff_put_vc1_mspel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
put_pixels8_c(dst, src, stride, 8);
}
-
-void ff_put_vc1_qpel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
- put_pixels8_c(dst, src, stride, 8);
-}
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h (original)
+++ trunk/libavcodec/dsputil.h Sat Sep 2 06:58:51 2006
@@ -398,7 +398,6 @@
* last argument is actually round value instead of height
*/
op_pixels_func put_vc1_mspel_pixels_tab[16];
- op_pixels_func put_vc1_qpel_pixels_tab[16];
} DSPContext;
void dsputil_static_init(void);
Modified: trunk/libavcodec/vc1dsp.c
==============================================================================
--- trunk/libavcodec/vc1dsp.c (original)
+++ trunk/libavcodec/vc1dsp.c Sat Sep 2 06:58:51 2006
@@ -424,169 +424,6 @@
vc1_mspel_mc(dst, src, stride, 0xF, rnd);
}
-/** Filter used to interpolate fractional pel values
- * except for half-pel cases for _mcXY:
- * A = (4-X)*(4-Y)
- * B = X *(4-Y)
- * C = (4-X)* Y
- * D = X * Y
- */
-#define VC1_QPEL_FILTER(src, i, stride, rnd, A, B, C, D) \
- clip_uint8((A*src[i] + B*src[i+1] + C*src[i+stride] + D*src[i+stride+1] + 8 - rnd) >> 4)
-
-/* this one is defined in dsputil.c */
-void ff_put_vc1_qpel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-
-static void ff_put_vc1_qpel_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 12, 4, 0, 0);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = clip_uint8((src[i] + src[i + 1] + 1 - rnd) >> 1);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc30_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 4, 12, 0, 0);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 12, 0, 4, 0);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 9, 3, 3, 1);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 6, 6, 2, 2);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc31_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 3, 9, 1, 3);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = clip_uint8((src[i] + src[i + stride] + 1 - rnd) >> 1);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 6, 2, 6, 2);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = clip_uint8((src[i] + src[i + 1] + src[i + stride] + src[i + stride + 1] + 2 - rnd) >> 2);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc32_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 2, 6, 2, 6);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc03_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 4, 0, 12, 0);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc13_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 3, 1, 9, 3);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc23_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 2, 2, 6, 6);
- dst += stride;
- src += stride;
- }
-}
-
-static void ff_put_vc1_qpel_mc33_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- int i, j;
- for(j = 0; j < 8; j++) {
- for(i = 0; i < 8; i++)
- dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 1, 3, 3, 9);
- dst += stride;
- src += stride;
- }
-}
-
void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
@@ -611,21 +448,4 @@
dsp->put_vc1_mspel_pixels_tab[13] = ff_put_vc1_mspel_mc13_c;
dsp->put_vc1_mspel_pixels_tab[14] = ff_put_vc1_mspel_mc23_c;
dsp->put_vc1_mspel_pixels_tab[15] = ff_put_vc1_mspel_mc33_c;
-
- dsp->put_vc1_qpel_pixels_tab[ 0] = ff_put_vc1_qpel_mc00_c;
- dsp->put_vc1_qpel_pixels_tab[ 1] = ff_put_vc1_qpel_mc10_c;
- dsp->put_vc1_qpel_pixels_tab[ 2] = ff_put_vc1_qpel_mc20_c;
- dsp->put_vc1_qpel_pixels_tab[ 3] = ff_put_vc1_qpel_mc30_c;
- dsp->put_vc1_qpel_pixels_tab[ 4] = ff_put_vc1_qpel_mc01_c;
- dsp->put_vc1_qpel_pixels_tab[ 5] = ff_put_vc1_qpel_mc11_c;
- dsp->put_vc1_qpel_pixels_tab[ 6] = ff_put_vc1_qpel_mc21_c;
- dsp->put_vc1_qpel_pixels_tab[ 7] = ff_put_vc1_qpel_mc31_c;
- dsp->put_vc1_qpel_pixels_tab[ 8] = ff_put_vc1_qpel_mc02_c;
- dsp->put_vc1_qpel_pixels_tab[ 9] = ff_put_vc1_qpel_mc12_c;
- dsp->put_vc1_qpel_pixels_tab[10] = ff_put_vc1_qpel_mc22_c;
- dsp->put_vc1_qpel_pixels_tab[11] = ff_put_vc1_qpel_mc32_c;
- dsp->put_vc1_qpel_pixels_tab[12] = ff_put_vc1_qpel_mc03_c;
- dsp->put_vc1_qpel_pixels_tab[13] = ff_put_vc1_qpel_mc13_c;
- dsp->put_vc1_qpel_pixels_tab[14] = ff_put_vc1_qpel_mc23_c;
- dsp->put_vc1_qpel_pixels_tab[15] = ff_put_vc1_qpel_mc33_c;
}
1
0
Author: kostya
Date: Sat Sep 2 06:52:00 2006
New Revision: 6150
Modified:
trunk/libavcodec/dsputil.c
trunk/libavcodec/dsputil.h
Log:
New function for chroma MC (will be used in VC-1)
Modified: trunk/libavcodec/dsputil.c
==============================================================================
--- trunk/libavcodec/dsputil.c (original)
+++ trunk/libavcodec/dsputil.c Sat Sep 2 06:52:00 2006
@@ -1487,6 +1487,30 @@
#undef op_avg
#undef op_put
+static void put_no_rnd_h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+ const int A=(8-x)*(8-y);
+ const int B=( x)*(8-y);
+ const int C=(8-x)*( y);
+ const int D=( x)*( y);
+ int i;
+
+ assert(x<8 && y<8 && x>=0 && y>=0);
+
+ for(i=0; i<h; i++)
+ {
+ dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
+ dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
+ dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
+ dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
+ dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
+ dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
+ dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
+ dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
+ dst+= stride;
+ src+= stride;
+ }
+}
+
static inline void copy_block2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
@@ -4034,6 +4058,7 @@
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
+ c->put_no_rnd_h264_chroma_pixels_tab[0]= put_no_rnd_h264_chroma_mc8_c;
c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;
c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;
Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h (original)
+++ trunk/libavcodec/dsputil.h Sat Sep 2 06:52:00 2006
@@ -270,6 +270,8 @@
* h264 Chram MC
*/
h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
+ /* This is really one func used in VC-1 decoding */
+ h264_chroma_mc_func put_no_rnd_h264_chroma_pixels_tab[3];
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
qpel_mc_func put_h264_qpel_pixels_tab[4][16];
1
0
Author: lorenm
Date: Sat Sep 2 00:02:38 2006
New Revision: 6149
Modified:
trunk/libavcodec/snow.c
Log:
snow cosmetics: merge the sliced and non-sliced versions of add_yblock
Modified: trunk/libavcodec/snow.c
==============================================================================
--- trunk/libavcodec/snow.c (original)
+++ trunk/libavcodec/snow.c Sat Sep 2 00:02:38 2006
@@ -2551,8 +2551,7 @@
}
//FIXME name clenup (b_w, block_w, b_width stuff)
-static always_inline void add_yblock_buffered(SnowContext *s, slice_buffer * sb, DWTELEM *old_dst, uint8_t *dst8, uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int plane_index){
- DWTELEM * dst = NULL;
+static always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, DWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
const int b_width = s->b_width << s->block_max_depth;
const int b_height= s->b_height << s->block_max_depth;
const int b_stride= b_width;
@@ -2584,136 +2583,7 @@
if(src_x<0){ //FIXME merge with prev & always round internal width upto *16
obmc -= src_x;
b_w += src_x;
- src_x=0;
- }else if(src_x + b_w > w){
- b_w = w - src_x;
- }
- if(src_y<0){
- obmc -= src_y*obmc_stride;
- b_h += src_y;
- src_y=0;
- }else if(src_y + b_h> h){
- b_h = h - src_y;
- }
-
- if(b_w<=0 || b_h<=0) return;
-
-assert(src_stride > 2*MB_SIZE + 5);
-// old_dst += src_x + src_y*dst_stride;
- dst8+= src_x + src_y*src_stride;
-// src += src_x + src_y*src_stride;
-
- ptmp= tmp + 3*tmp_step;
- block[0]= ptmp;
- ptmp+=tmp_step;
- pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h);
-
- if(same_block(lt, rt)){
- block[1]= block[0];
- }else{
- block[1]= ptmp;
- ptmp+=tmp_step;
- pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h);
- }
-
- if(same_block(lt, lb)){
- block[2]= block[0];
- }else if(same_block(rt, lb)){
- block[2]= block[1];
- }else{
- block[2]= ptmp;
- ptmp+=tmp_step;
- pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h);
- }
-
- if(same_block(lt, rb) ){
- block[3]= block[0];
- }else if(same_block(rt, rb)){
- block[3]= block[1];
- }else if(same_block(lb, rb)){
- block[3]= block[2];
- }else{
- block[3]= ptmp;
- pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h);
- }
-#if 0
- for(y=0; y<b_h; y++){
- for(x=0; x<b_w; x++){
- int v= obmc [x + y*obmc_stride] * block[3][x + y*src_stride] * (256/OBMC_MAX);
- if(add) dst[x + y*dst_stride] += v;
- else dst[x + y*dst_stride] -= v;
- }
- }
- for(y=0; y<b_h; y++){
- uint8_t *obmc2= obmc + (obmc_stride>>1);
- for(x=0; x<b_w; x++){
- int v= obmc2[x + y*obmc_stride] * block[2][x + y*src_stride] * (256/OBMC_MAX);
- if(add) dst[x + y*dst_stride] += v;
- else dst[x + y*dst_stride] -= v;
- }
- }
- for(y=0; y<b_h; y++){
- uint8_t *obmc3= obmc + obmc_stride*(obmc_stride>>1);
- for(x=0; x<b_w; x++){
- int v= obmc3[x + y*obmc_stride] * block[1][x + y*src_stride] * (256/OBMC_MAX);
- if(add) dst[x + y*dst_stride] += v;
- else dst[x + y*dst_stride] -= v;
- }
- }
- for(y=0; y<b_h; y++){
- uint8_t *obmc3= obmc + obmc_stride*(obmc_stride>>1);
- uint8_t *obmc4= obmc3+ (obmc_stride>>1);
- for(x=0; x<b_w; x++){
- int v= obmc4[x + y*obmc_stride] * block[0][x + y*src_stride] * (256/OBMC_MAX);
- if(add) dst[x + y*dst_stride] += v;
- else dst[x + y*dst_stride] -= v;
- }
- }
-#else
-{
-
- START_TIMER
-
- s->dsp.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
- STOP_TIMER("Inner add y block")
-}
-#endif
-}
-
-//FIXME name clenup (b_w, block_w, b_width stuff)
-static always_inline void add_yblock(SnowContext *s, DWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
- const int b_width = s->b_width << s->block_max_depth;
- const int b_height= s->b_height << s->block_max_depth;
- const int b_stride= b_width;
- BlockNode *lt= &s->block[b_x + b_y*b_stride];
- BlockNode *rt= lt+1;
- BlockNode *lb= lt+b_stride;
- BlockNode *rb= lb+1;
- uint8_t *block[4];
- int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
- uint8_t tmp[src_stride*7*MB_SIZE]; //FIXME align
- uint8_t *ptmp;
- int x,y;
-
- if(b_x<0){
- lt= rt;
- lb= rb;
- }else if(b_x + 1 >= b_width){
- rt= lt;
- rb= lb;
- }
- if(b_y<0){
- lt= lb;
- rt= rb;
- }else if(b_y + 1 >= b_height){
- lb= lt;
- rb= rt;
- }
-
- if(src_x<0){ //FIXME merge with prev & always round internal width upto *16
- obmc -= src_x;
- b_w += src_x;
- if(!offset_dst)
+ if(!sliced && !offset_dst)
dst -= src_x;
src_x=0;
}else if(src_x + b_w > w){
@@ -2722,7 +2592,7 @@
if(src_y<0){
obmc -= src_y*obmc_stride;
b_h += src_y;
- if(!offset_dst)
+ if(!sliced && !offset_dst)
dst -= src_y*dst_stride;
src_y=0;
}else if(src_y + b_h> h){
@@ -2732,7 +2602,7 @@
if(b_w<=0 || b_h<=0) return;
assert(src_stride > 2*MB_SIZE + 5);
- if(offset_dst)
+ if(!sliced && offset_dst)
dst += src_x + src_y*dst_stride;
dst8+= src_x + src_y*src_stride;
// src += src_x + src_y*src_stride;
@@ -2804,6 +2674,12 @@
}
}
#else
+ if(sliced){
+ START_TIMER
+
+ s->dsp.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
+ STOP_TIMER("inner_add_yblock")
+ }else
for(y=0; y<b_h; y++){
//FIXME ugly missue of obmc_stride
uint8_t *obmc1= obmc + y*obmc_stride;
@@ -2886,14 +2762,14 @@
for(mb_x=0; mb_x<=mb_w; mb_x++){
START_TIMER
- add_yblock_buffered(s, sb, old_buffer, dst8, obmc,
+ add_yblock(s, 1, sb, old_buffer, dst8, obmc,
block_w*mb_x - block_w/2,
block_w*mb_y - block_w/2,
block_w, block_w,
w, h,
w, ref_stride, obmc_stride,
mb_x - 1, mb_y - 1,
- add, plane_index);
+ add, 0, plane_index);
STOP_TIMER("add_yblock")
}
@@ -2943,7 +2819,7 @@
for(mb_x=0; mb_x<=mb_w; mb_x++){
START_TIMER
- add_yblock(s, buf, dst8, obmc,
+ add_yblock(s, 0, NULL, buf, dst8, obmc,
block_w*mb_x - block_w/2,
block_w*mb_y - block_w/2,
block_w, block_w,
@@ -2994,7 +2870,7 @@
int x= block_w*mb_x2 + block_w/2;
int y= block_w*mb_y2 + block_w/2;
- add_yblock(s, dst + ((i&1)+(i>>1)*obmc_stride)*block_w, NULL, obmc,
+ add_yblock(s, 0, NULL, dst + ((i&1)+(i>>1)*obmc_stride)*block_w, NULL, obmc,
x, y, block_w, block_w, w, h, obmc_stride, ref_stride, obmc_stride, mb_x2, mb_y2, 0, 0, plane_index);
for(y2= FFMAX(y, 0); y2<FFMIN(h, y+block_w); y2++){
@@ -3178,7 +3054,7 @@
int x= block_w*mb_x2 + block_w/2;
int y= block_w*mb_y2 + block_w/2;
- add_yblock(s, zero_dst, dst, obmc,
+ add_yblock(s, 0, NULL, zero_dst, dst, obmc,
x, y, block_w, block_w, w, h, /*dst_stride*/0, ref_stride, obmc_stride, mb_x2, mb_y2, 1, 1, plane_index);
//FIXME find a cleaner/simpler way to skip the outside stuff
3
2
Author: lorenm
Date: Fri Sep 1 23:51:35 2006
New Revision: 6148
Modified:
trunk/libavcodec/snow.c
Log:
fix snow 1pass rc: the qlog used and the one written to the bitstream weren't always the same.
Modified: trunk/libavcodec/snow.c
==============================================================================
--- trunk/libavcodec/snow.c (original)
+++ trunk/libavcodec/snow.c Fri Sep 1 23:51:35 2006
@@ -2317,12 +2317,12 @@
}
}
-static void encode_blocks(SnowContext *s){
+static void encode_blocks(SnowContext *s, int search){
int x, y;
int w= s->b_width;
int h= s->b_height;
- if(s->avctx->me_method == ME_ITER && !s->keyframe)
+ if(s->avctx->me_method == ME_ITER && !s->keyframe && search)
iterative_me(s);
for(y=0; y<h; y++){
@@ -2331,7 +2331,7 @@
return;
}
for(x=0; x<w; x++){
- if(s->avctx->me_method == ME_ITER)
+ if(s->avctx->me_method == ME_ITER || !search)
encode_q_branch2(s, 0, x, y);
else
encode_q_branch (s, 0, x, y);
@@ -3957,13 +3957,13 @@
+ 61*QROOT/8; //<64 >60
}
-static void ratecontrol_1pass(SnowContext *s, AVFrame *pict)
+static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
{
/* estimate the frame's complexity as a sum of weighted dwt coefs.
* FIXME we know exact mv bits at this point,
* but ratecontrol isn't set up to include them. */
uint32_t coef_sum= 0;
- int level, orientation;
+ int level, orientation, delta_qlog;
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
@@ -4000,7 +4000,9 @@
pict->quality= ff_rate_estimate_qscale(&s->m, 1);
s->lambda= pict->quality * 3/2;
- s->qlog= qscale2qlog(pict->quality);
+ delta_qlog= qscale2qlog(pict->quality) - s->qlog;
+ s->qlog+= delta_qlog;
+ return delta_qlog;
}
static void calculate_vissual_weight(SnowContext *s, Plane *p){
@@ -4162,6 +4164,8 @@
const int width= s->avctx->width;
const int height= s->avctx->height;
int level, orientation, plane_index, i, y;
+ uint8_t rc_header_bak[sizeof(s->header_state)];
+ uint8_t rc_block_bak[sizeof(s->block_state)];
ff_init_range_encoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
@@ -4244,6 +4248,11 @@
s->dsp= s->m.dsp;
}
+ if(s->pass1_rc){
+ memcpy(rc_header_bak, s->header_state, sizeof(s->header_state));
+ memcpy(rc_block_bak, s->block_state, sizeof(s->block_state));
+ }
+
redo_frame:
s->m.pict_type = pict->pict_type;
@@ -4251,7 +4260,7 @@
encode_header(s);
s->m.misc_bits = 8*(s->c.bytestream - s->c.bytestream_start);
- encode_blocks(s);
+ encode_blocks(s, 1);
s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits;
for(plane_index=0; plane_index<3; plane_index++){
@@ -4294,8 +4303,17 @@
ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
- if(s->pass1_rc && plane_index==0)
- ratecontrol_1pass(s, pict);
+ if(s->pass1_rc && plane_index==0){
+ int delta_qlog = ratecontrol_1pass(s, pict);
+ if(delta_qlog){
+ //reordering qlog in the bitstream would eliminate this reset
+ ff_init_range_encoder(c, buf, buf_size);
+ memcpy(s->header_state, rc_header_bak, sizeof(s->header_state));
+ memcpy(s->block_state, rc_block_bak, sizeof(s->block_state));
+ encode_header(s);
+ encode_blocks(s, 0);
+ }
+ }
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
1
0
r5787 - in trunk: MAINTAINERS libavformat/Makefile libavformat/allformats.c libavformat/allformats.h libavformat/gxf.h libavformat/gxfenc.c
by subversion@mplayerhq.hu 01 Sep '06
by subversion@mplayerhq.hu 01 Sep '06
01 Sep '06
Author: bcoudurier
Date: Wed Jul 19 11:38:22 2006
New Revision: 5787
Added:
trunk/libavformat/gxf.h
trunk/libavformat/gxfenc.c
Modified:
trunk/MAINTAINERS
trunk/libavformat/Makefile
trunk/libavformat/allformats.c
trunk/libavformat/allformats.h
Log:
GXF muxer
Modified: trunk/MAINTAINERS
==============================================================================
--- trunk/MAINTAINERS (original)
+++ trunk/MAINTAINERS Wed Jul 19 11:38:22 2006
@@ -191,6 +191,7 @@
flic.c Mike Melanson
flvdec.c, flvenc.c Michael Niedermayer
gxf.c Reimar Doeffinger
+ gxfenc.c Baptiste Coudurier
idcin.c Mike Melanson
idroq.c Mike Melanson
ipmovie.c Mike Melanson
Modified: trunk/libavformat/Makefile
==============================================================================
--- trunk/libavformat/Makefile (original)
+++ trunk/libavformat/Makefile Wed Jul 19 11:38:22 2006
@@ -183,6 +183,10 @@
OBJS-$(CONFIG_OGG_MUXER) += ogg.o
endif
+ifeq ($(CONFIG_GPL),yes)
+OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o
+endif
+
OBJS += $(OBJS-yes)
NAME=avformat
Modified: trunk/libavformat/allformats.c
==============================================================================
--- trunk/libavformat/allformats.c (original)
+++ trunk/libavformat/allformats.c Wed Jul 19 11:38:22 2006
@@ -138,6 +138,9 @@
#ifdef CONFIG_GXF_DEMUXER
av_register_input_format(&gxf_demuxer);
#endif
+#if defined(CONFIG_GXF_MUXER) && defined(CONFIG_GPL)
+ av_register_output_format(&gxf_muxer);
+#endif
#ifdef CONFIG_IDCIN_DEMUXER
av_register_input_format(&idcin_demuxer);
#endif
Modified: trunk/libavformat/allformats.h
==============================================================================
--- trunk/libavformat/allformats.h (original)
+++ trunk/libavformat/allformats.h Wed Jul 19 11:38:22 2006
@@ -35,6 +35,7 @@
extern AVInputFormat video_grab_device_demuxer;
extern AVInputFormat video_grab_device_demuxer;
extern AVInputFormat gxf_demuxer;
+extern AVOutputFormat gxf_muxer;
extern AVInputFormat idcin_demuxer;
extern AVInputFormat roq_demuxer;
extern AVInputFormat image2_demuxer;
Added: trunk/libavformat/gxf.h
==============================================================================
--- (empty file)
+++ trunk/libavformat/gxf.h Wed Jul 19 11:38:22 2006
@@ -0,0 +1,13 @@
+#ifndef FFMPEG_GXF_H
+#define FFMPEG_GXF_H
+
+/* gxf.c */
+typedef enum {
+ PKT_MAP = 0xbc,
+ PKT_MEDIA = 0xbf,
+ PKT_EOS = 0xfb,
+ PKT_FLT = 0xfc,
+ PKT_UMF = 0xfd
+} pkt_type_t;
+
+#endif /* FFMPEG_GXF_H */
Added: trunk/libavformat/gxfenc.c
==============================================================================
--- (empty file)
+++ trunk/libavformat/gxfenc.c Wed Jul 19 11:38:22 2006
@@ -0,0 +1,823 @@
+/*
+ * GXF muxer.
+ * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "gxf.h"
+#include "riff.h"
+
+#define GXF_AUDIO_PACKET_SIZE 65536
+
+typedef struct GXFStreamContext {
+ AVCodecContext *codec;
+ FifoBuffer audio_buffer;
+ uint32_t track_type;
+ uint32_t sample_size;
+ uint32_t sample_rate;
+ uint16_t media_type;
+ uint16_t media_info;
+ uint8_t index;
+ int frame_rate_index;
+ int lines_index;
+ int fields;
+ int iframes;
+ int pframes;
+ int bframes;
+ int p_per_gop;
+ int b_per_gop;
+} GXFStreamContext;
+
+typedef struct GXFContext {
+ uint32_t nb_frames;
+ uint32_t material_flags;
+ uint16_t audio_tracks;
+ uint16_t mpeg_tracks;
+ int64_t creation_time;
+ uint32_t umf_start_offset;
+ uint32_t umf_track_offset;
+ uint32_t umf_media_offset;
+ uint32_t umf_user_data_offset;
+ uint32_t umf_user_data_size;
+ uint32_t umf_length;
+ uint16_t umf_track_size;
+ uint16_t umf_media_size;
+ int audio_written;
+ int sample_rate;
+ int field_number;
+ int flags;
+ AVFormatContext *fc;
+ GXFStreamContext streams[48];
+} GXFContext;
+
+typedef struct GXF_Lines {
+ int height;
+ int index;
+} GXF_Lines;
+
+
+/* FIXME check if it is relevant */
+static const GXF_Lines gxf_lines_tab[] = {
+ { 480, 1 }, /* NTSC */
+ { 512, 1 }, /* NTSC + VBI */
+ { 576, 2 }, /* PAL */
+ { 608, 2 }, /* PAL + VBI */
+ { 1080, 4 },
+ { 720, 6 },
+};
+
+static const CodecTag gxf_media_types[] = {
+ { CODEC_ID_MJPEG , 3 }, /* NTSC */
+ { CODEC_ID_MJPEG , 4 }, /* PAL */
+ { CODEC_ID_PCM_S24LE , 9 },
+ { CODEC_ID_PCM_S16LE , 10 },
+ { CODEC_ID_MPEG2VIDEO, 11 }, /* NTSC */
+ { CODEC_ID_MPEG2VIDEO, 12 }, /* PAL */
+ { CODEC_ID_DVVIDEO , 13 }, /* NTSC */
+ { CODEC_ID_DVVIDEO , 14 }, /* PAL */
+ { CODEC_ID_DVVIDEO , 15 }, /* 50M NTSC */
+ { CODEC_ID_DVVIDEO , 16 }, /* 50M PAL */
+ { CODEC_ID_AC3 , 17 },
+ //{ CODEC_ID_NONE, , 18 }, /* Non compressed 24 bit audio */
+ { CODEC_ID_MPEG2VIDEO, 20 }, /* MPEG HD */
+ { CODEC_ID_MPEG1VIDEO, 22 }, /* NTSC */
+ { CODEC_ID_MPEG1VIDEO, 23 }, /* PAL */
+ { 0, 0 },
+};
+
+#define SERVER_PATH "/space/"
+#define ES_NAME_PATTERN "ES."
+
+static int gxf_find_lines_index(GXFStreamContext *ctx)
+{
+ int i;
+
+ for (i = 0; i < 6; ++i) {
+ if (ctx->codec->height == gxf_lines_tab[i].height) {
+ ctx->lines_index = gxf_lines_tab[i].index;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void gxf_write_padding(ByteIOContext *pb, offset_t to_pad)
+{
+ while (to_pad--) {
+ put_byte(pb, 0);
+ }
+}
+
+static offset_t updatePacketSize(ByteIOContext *pb, offset_t pos)
+{
+ offset_t curpos;
+ int size;
+
+ size = url_ftell(pb) - pos;
+ if (size % 4) {
+ gxf_write_padding(pb, 4 - size % 4);
+ size = url_ftell(pb) - pos;
+ }
+ curpos = url_ftell(pb);
+ url_fseek(pb, pos + 6, SEEK_SET);
+ put_be32(pb, size);
+ url_fseek(pb, curpos, SEEK_SET);
+ return curpos - pos;
+}
+
+static offset_t updateSize(ByteIOContext *pb, offset_t pos)
+{
+ offset_t curpos;
+
+ curpos = url_ftell(pb);
+ url_fseek(pb, pos, SEEK_SET);
+ put_be16(pb, curpos - pos - 2);
+ url_fseek(pb, curpos, SEEK_SET);
+ return curpos - pos;
+}
+
+static void gxf_write_packet_header(ByteIOContext *pb, pkt_type_t type)
+{
+ put_be32(pb, 0); /* packet leader for synchro */
+ put_byte(pb, 1);
+ put_byte(pb, type); /* map packet */
+ put_be32(pb, 0); /* size */
+ put_be32(pb, 0); /* reserved */
+ put_byte(pb, 0xE1); /* trailer 1 */
+ put_byte(pb, 0xE2); /* trailer 2 */
+}
+
+static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
+{
+ char buffer[1024];
+ int size;
+
+ if (ctx->iframes) {
+ ctx->p_per_gop = ctx->pframes / ctx->iframes;
+ if (ctx->pframes % ctx->iframes)
+ ctx->p_per_gop++;
+ if (ctx->pframes)
+ ctx->b_per_gop = ctx->bframes / ctx->pframes;
+ if (ctx->p_per_gop > 9)
+ ctx->p_per_gop = 9; /* ensure value won't take more than one char */
+ if (ctx->b_per_gop > 9)
+ ctx->b_per_gop = 9; /* ensure value won't take more than one char */
+ }
+ size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
+ "Pix 0\nCf %d\nCg 1\nSl 7\nnl16 %d\nVi 1\nf1 1\n",
+ (float)ctx->codec->bit_rate, ctx->p_per_gop, ctx->b_per_gop,
+ ctx->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1,
+ ctx->codec->height / 16);
+ put_byte(pb, 0x4F);
+ put_byte(pb, size + 1);
+ put_buffer(pb, (uint8_t *)buffer, size + 1);
+ return size + 3;
+}
+
+static int gxf_write_timecode_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
+{
+ /* FIXME implement that */
+ put_byte(pb, 0); /* fields */
+ put_byte(pb, 0); /* seconds */
+ put_byte(pb, 0); /* minutes */
+ put_byte(pb, 0); /* flags + hours */
+ /* reserved */
+ put_be32(pb, 0);
+ return 8;
+}
+
+static int gxf_write_track_description(ByteIOContext *pb, GXFStreamContext *stream)
+{
+ offset_t pos;
+
+ /* track description section */
+ put_byte(pb, stream->media_type + 0x80);
+ put_byte(pb, stream->index + 0xC0);
+
+ pos = url_ftell(pb);
+ put_be16(pb, 0); /* size */
+
+ /* media file name */
+ put_byte(pb, 0x4C);
+ put_byte(pb, strlen(ES_NAME_PATTERN) + 3);
+ put_tag(pb, ES_NAME_PATTERN);
+ put_be16(pb, stream->media_info);
+ put_byte(pb, 0);
+
+ if (stream->codec->codec_id != CODEC_ID_MPEG2VIDEO) {
+ /* auxiliary information */
+ put_byte(pb, 0x4D);
+ put_byte(pb, 8);
+ if (stream->codec->codec_id == CODEC_ID_NONE)
+ gxf_write_timecode_auxiliary(pb, stream);
+ else
+ put_le64(pb, 0);
+ }
+
+ /* file system version */
+ put_byte(pb, 0x4E);
+ put_byte(pb, 4);
+ put_be32(pb, 0);
+
+ if (stream->codec->codec_id == CODEC_ID_MPEG2VIDEO)
+ gxf_write_mpeg_auxiliary(pb, stream);
+
+ /* frame rate */
+ put_byte(pb, 0x50);
+ put_byte(pb, 4);
+ put_be32(pb, stream->frame_rate_index);
+
+ /* lines per frame */
+ put_byte(pb, 0x51);
+ put_byte(pb, 4);
+ put_be32(pb, stream->lines_index);
+
+ /* fields per frame */
+ put_byte(pb, 0x52);
+ put_byte(pb, 4);
+ put_be32(pb, stream->fields);
+
+ return updateSize(pb, pos);
+}
+
+static int gxf_write_material_data_section(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos;
+ const char *filename = strrchr(ctx->fc->filename, '/');
+
+ pos = url_ftell(pb);
+ put_be16(pb, 0); /* size */
+
+ /* name */
+ if (filename)
+ filename++;
+ else
+ filename = ctx->fc->filename;
+ put_byte(pb, 0x40);
+ put_byte(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
+ put_tag(pb, SERVER_PATH);
+ put_tag(pb, filename);
+ put_byte(pb, 0);
+
+ /* first field */
+ put_byte(pb, 0x41);
+ put_byte(pb, 4);
+ put_be32(pb, 0);
+
+ /* last field */
+ put_byte(pb, 0x42);
+ put_byte(pb, 4);
+ put_be32(pb, ctx->nb_frames);
+
+ /* reserved */
+ put_byte(pb, 0x43);
+ put_byte(pb, 4);
+ put_be32(pb, 0);
+
+ put_byte(pb, 0x44);
+ put_byte(pb, 4);
+ put_be32(pb, ctx->nb_frames);
+
+ /* estimated size */
+ put_byte(pb, 0x45);
+ put_byte(pb, 4);
+ put_be32(pb, url_fsize(pb) / 1024);
+
+ return updateSize(pb, pos);
+}
+
+static int gxf_write_track_description_section(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos;
+ int i;
+
+ pos = url_ftell(pb);
+ put_be16(pb, 0); /* size */
+ for (i = 0; i < ctx->fc->nb_streams; ++i)
+ gxf_write_track_description(pb, &ctx->streams[i]);
+ return updateSize(pb, pos);
+}
+
+static int gxf_write_map_packet(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+
+ gxf_write_packet_header(pb, PKT_MAP);
+
+ /* preamble */
+ put_byte(pb, 0xE0); /* version */
+ put_byte(pb, 0xFF); /* reserved */
+
+ gxf_write_material_data_section(pb, ctx);
+ gxf_write_track_description_section(pb, ctx);
+
+ return updatePacketSize(pb, pos);
+}
+
+#if 0
+static int gxf_write_flt_packet(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+ int i;
+
+ gxf_write_packet_header(pb, PKT_FLT);
+
+ put_le32(pb, 1000); /* number of fields */
+ put_le32(pb, 0); /* number of active flt entries */
+
+ for (i = 0; i < 1000; ++i) {
+ put_le32(pb, 0);
+ }
+ return updatePacketSize(pb, pos);
+}
+#endif
+
+static int gxf_write_umf_material_description(ByteIOContext *pb, GXFContext *ctx)
+{
+ put_le32(pb, ctx->flags);
+ put_le32(pb, ctx->nb_frames); /* length of the longest track */
+ put_le32(pb, ctx->nb_frames); /* length of the shortest track */
+ put_le32(pb, 0); /* mark in */
+ put_le32(pb, ctx->nb_frames); /* mark out */
+ put_le32(pb, 0); /* timecode mark in */
+ put_le32(pb, ctx->nb_frames); /* timecode mark out */
+ put_le64(pb, ctx->fc->timestamp); /* modification time */
+ put_le64(pb, ctx->fc->timestamp); /* creation time */
+ put_le16(pb, 0); /* reserved */
+ put_le16(pb, 0); /* reserved */
+ put_le16(pb, ctx->audio_tracks);
+ put_le16(pb, 0); /* timecode track count */
+ put_le16(pb, 0); /* reserved */
+ put_le16(pb, ctx->mpeg_tracks);
+ return 48;
+}
+
+static int gxf_write_umf_payload(ByteIOContext *pb, GXFContext *ctx)
+{
+ put_le32(pb, ctx->umf_length); /* total length of the umf data */
+ put_le32(pb, 3); /* version */
+ put_le32(pb, ctx->fc->nb_streams);
+ put_le32(pb, ctx->umf_track_offset); /* umf track section offset */
+ put_le32(pb, ctx->umf_track_size);
+ put_le32(pb, ctx->fc->nb_streams);
+ put_le32(pb, ctx->umf_media_offset);
+ put_le32(pb, ctx->umf_media_size);
+ put_le32(pb, ctx->umf_user_data_offset); /* user data offset */
+ put_le32(pb, ctx->umf_user_data_size); /* user data size */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ return 48;
+}
+
+static int gxf_write_umf_track_description(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+ int tracks[255]={0};
+ int i;
+
+ ctx->umf_track_offset = pos - ctx->umf_start_offset;
+ for (i = 0; i < ctx->fc->nb_streams; ++i) {
+ AVStream *st = ctx->fc->streams[i];
+ GXFStreamContext *sc = &ctx->streams[i];
+ int id = 0;
+
+ switch (st->codec->codec_id) {
+ case CODEC_ID_MPEG1VIDEO: id= 'L'; break;
+ case CODEC_ID_MPEG2VIDEO: id= 'M'; break;
+ case CODEC_ID_PCM_S16LE: id= 'A'; break;
+ case CODEC_ID_DVVIDEO: id= sc->track_type == 6 ? 'E' : 'D'; break;
+ case CODEC_ID_MJPEG: id= 'V'; break;
+ }
+ sc->media_info= id << 8;
+ /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
+ sc->media_info |= '0' + (tracks[id]++);
+ put_le16(pb, sc->media_info);
+ put_le16(pb, 1);
+ }
+ return url_ftell(pb) - pos;
+}
+
+static int gxf_write_umf_media_mpeg(ByteIOContext *pb, GXFStreamContext *stream)
+{
+ if (stream->codec->pix_fmt == PIX_FMT_YUV422P)
+ put_le32(pb, 2);
+ else
+ put_le32(pb, 1); /* default to 420 */
+ put_le32(pb, 1); /* closed = 1, open = 0, unknown = 255 */
+ put_le32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
+ put_le32(pb, 1); /* I picture per GOP */
+ put_le32(pb, stream->p_per_gop);
+ put_le32(pb, stream->b_per_gop);
+ if (stream->codec->codec_id == CODEC_ID_MPEG2VIDEO)
+ put_le32(pb, 2);
+ else if (stream->codec->codec_id == CODEC_ID_MPEG1VIDEO)
+ put_le32(pb, 1);
+ else
+ put_le32(pb, 0);
+ put_le32(pb, 0); /* reserved */
+ return 32;
+}
+
+static int gxf_write_umf_media_timecode(ByteIOContext *pb, GXFStreamContext *track)
+{
+ /* FIXME implement */
+ put_be32(pb, 0); /* drop frame flag */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ put_be32(pb, 0); /* reserved */
+ return 32;
+}
+
+static int gxf_write_umf_media_dv(ByteIOContext *pb, GXFStreamContext *track)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ put_be32(pb, 0);
+ }
+ return 32;
+}
+
+static int gxf_write_umf_media_audio(ByteIOContext *pb, GXFStreamContext *track)
+{
+ put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
+ put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
+ put_le32(pb, 0); /* number of fields over which to ramp up sound level */
+ put_le32(pb, 0); /* number of fields over which to ramp down sound level */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ return 32;
+}
+
+#if 0
+static int gxf_write_umf_media_mjpeg(ByteIOContext *pb, GXFStreamContext *track)
+{
+ put_be64(pb, 0); /* FIXME FLOAT max chroma quant level */
+ put_be64(pb, 0); /* FIXME FLOAT max luma quant level */
+ put_be64(pb, 0); /* FIXME FLOAT min chroma quant level */
+ put_be64(pb, 0); /* FIXME FLOAT min luma quant level */
+ return 32;
+}
+#endif
+
+static int gxf_write_umf_media_description(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos;
+ int i;
+
+ pos = url_ftell(pb);
+ ctx->umf_media_offset = pos - ctx->umf_start_offset;
+ for (i = 0; i < ctx->fc->nb_streams; ++i) {
+ GXFStreamContext *sc = &ctx->streams[i];
+ char buffer[88];
+ offset_t startpos, curpos;
+ int path_size = strlen(ES_NAME_PATTERN);
+
+ startpos = url_ftell(pb);
+ put_le16(pb, 0); /* length */
+ put_le16(pb, sc->media_info);
+ put_le16(pb, 0); /* reserved */
+ put_le16(pb, 0); /* reserved */
+ put_le32(pb, ctx->nb_frames);
+ put_le32(pb, 0); /* attributes rw, ro */
+ put_le32(pb, 0); /* mark in */
+ put_le32(pb, ctx->nb_frames); /* mark out */
+ strncpy(buffer, ES_NAME_PATTERN, path_size);
+ put_buffer(pb, (uint8_t *)buffer, path_size);
+ put_be16(pb, sc->media_info);
+ put_buffer(pb, (uint8_t *)buffer + path_size + 2, 88 - path_size - 2);
+ put_le32(pb, sc->track_type);
+ put_le32(pb, sc->sample_rate);
+ put_le32(pb, sc->sample_size);
+ put_le32(pb, 0); /* reserved */
+ switch (sc->codec->codec_id) {
+ case CODEC_ID_MPEG2VIDEO:
+ gxf_write_umf_media_mpeg(pb, sc);
+ break;
+ case CODEC_ID_PCM_S16LE:
+ gxf_write_umf_media_audio(pb, sc);
+ break;
+ case CODEC_ID_DVVIDEO:
+ gxf_write_umf_media_dv(pb, sc);
+ break;
+ default:
+ gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
+ }
+ curpos = url_ftell(pb);
+ url_fseek(pb, startpos, SEEK_SET);
+ put_le16(pb, curpos - startpos);
+ url_fseek(pb, curpos, SEEK_SET);
+ }
+ return url_ftell(pb) - pos;
+}
+
+static int gxf_write_umf_user_data(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+ ctx->umf_user_data_offset = pos - ctx->umf_start_offset;
+ put_le32(pb, 20);
+ put_le32(pb, 0);
+ put_le16(pb, 0);
+ put_le16(pb, 0);
+ put_le32(pb, 0);
+ put_byte(pb, 0);
+ put_byte(pb, 0);
+ put_byte(pb, 0);
+ put_byte(pb, 0);
+ return 20;
+}
+
+static int gxf_write_umf_packet(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+
+ gxf_write_packet_header(pb, PKT_UMF);
+
+ /* preamble */
+ put_byte(pb, 3); /* first and last (only) packet */
+ put_be32(pb, ctx->umf_length); /* data length */
+
+ ctx->umf_start_offset = url_ftell(pb);
+ gxf_write_umf_payload(pb, ctx);
+ gxf_write_umf_material_description(pb, ctx);
+ ctx->umf_track_size = gxf_write_umf_track_description(pb, ctx);
+ ctx->umf_media_size = gxf_write_umf_media_description(pb, ctx);
+ ctx->umf_user_data_size = gxf_write_umf_user_data(pb, ctx);
+ ctx->umf_length = url_ftell(pb) - ctx->umf_start_offset;
+ return updatePacketSize(pb, pos);
+}
+
+static int gxf_write_header(AVFormatContext *s)
+{
+ ByteIOContext *pb = &s->pb;
+ GXFContext *gxf = s->priv_data;
+ int i;
+
+ gxf->fc = s;
+ gxf->flags |= 0x00080000; /* material is simple clip */
+ for (i = 0; i < s->nb_streams; ++i) {
+ AVStream *st = s->streams[i];
+ GXFStreamContext *sc = &gxf->streams[i];
+
+ sc->codec = st->codec;
+ sc->index = i;
+ sc->media_type = codec_get_tag(gxf_media_types, sc->codec->codec_id);
+ if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+ if (st->codec->codec_id != CODEC_ID_PCM_S16LE) {
+ av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
+ return -1;
+ }
+ if (st->codec->sample_rate != 48000) {
+ av_log(s, AV_LOG_ERROR, "only 48000hz sampling rate is allowed\n");
+ return -1;
+ }
+ if (st->codec->channels != 1) {
+ av_log(s, AV_LOG_ERROR, "only mono tracks are allowed\n");
+ return -1;
+ }
+ sc->track_type = 2;
+ sc->sample_rate = st->codec->sample_rate;
+ sc->sample_size = 16;
+ sc->frame_rate_index = -2;
+ sc->lines_index = -2;
+ sc->fields = -2;
+ gxf->audio_tracks++;
+ gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
+ fifo_init(&sc->audio_buffer, 3*GXF_AUDIO_PACKET_SIZE);
+ } else if (sc->codec->codec_type == CODEC_TYPE_VIDEO) {
+ /* FIXME check from time_base ? */
+ if (sc->codec->height == 480 || sc->codec->height == 512) { /* NTSC or NTSC+VBI */
+ sc->frame_rate_index = 5;
+ sc->sample_rate = 60;
+ gxf->flags |= 0x00000080;
+ } else { /* assume PAL */
+ sc->frame_rate_index = 6;
+ sc->media_type++;
+ sc->sample_rate = 50;
+ gxf->flags |= 0x00000040;
+ }
+ gxf->sample_rate = sc->sample_rate;
+ if (gxf_find_lines_index(sc) < 0)
+ sc->lines_index = -1;
+ sc->sample_size = st->codec->bit_rate;
+ sc->fields = 2; /* interlaced */
+ switch (sc->codec->codec_id) {
+ case CODEC_ID_MPEG2VIDEO:
+ sc->track_type = 4;
+ gxf->mpeg_tracks++;
+ gxf->flags |= 0x00008000;
+ break;
+ case CODEC_ID_DVVIDEO:
+ if (sc->codec->pix_fmt == PIX_FMT_YUV422P) {
+ sc->media_type += 2;
+ sc->track_type = 6;
+ gxf->flags |= 0x00002000;
+ } else {
+ sc->track_type = 5;
+ gxf->flags |= 0x00001000;
+ }
+ break;
+ default:
+ av_log(NULL, AV_LOG_ERROR, "video codec not supported\n");
+ return -1;
+ }
+ }
+ }
+ gxf_write_map_packet(pb, gxf);
+ //gxf_write_flt_packet(pb, gxf);
+ gxf_write_umf_packet(pb, gxf);
+ put_flush_packet(pb);
+ return 0;
+}
+
+static int gxf_write_eos_packet(ByteIOContext *pb, GXFContext *ctx)
+{
+ offset_t pos = url_ftell(pb);
+
+ gxf_write_packet_header(pb, PKT_EOS);
+ return updatePacketSize(pb, pos);
+}
+
+static int gxf_write_trailer(AVFormatContext *s)
+{
+ ByteIOContext *pb = &s->pb;
+ GXFContext *gxf = s->priv_data;
+ offset_t end;
+ int i;
+
+ for (i = 0; i < s->nb_streams; ++i) {
+ if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
+ fifo_free(&gxf->streams[i].audio_buffer);
+ }
+ if (s->streams[i]->codec->frame_number > gxf->nb_frames)
+ gxf->nb_frames = 2 * s->streams[i]->codec->frame_number;
+ }
+
+ gxf_write_eos_packet(pb, gxf);
+ end = url_ftell(pb);
+ url_fseek(pb, 0, SEEK_SET);
+ /* overwrite map and umf packets with new values */
+ gxf_write_map_packet(pb, gxf);
+ //gxf_write_flt_packet(pb, gxf);
+ gxf_write_umf_packet(pb, gxf);
+ url_fseek(pb, end, SEEK_SET);
+ return 0;
+}
+
+static int gxf_write_media_preamble(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt, int size)
+{
+ GXFStreamContext *sc = &ctx->streams[pkt->stream_index];
+
+ put_byte(pb, sc->media_type);
+ put_byte(pb, sc->index);
+ put_be32(pb, ctx->field_number);
+ if (sc->codec->codec_type == CODEC_TYPE_AUDIO) {
+ put_be16(pb, 0);
+ put_be16(pb, size / 2);
+ } else if (sc->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
+ if (pkt->flags & PKT_FLAG_KEY) {
+ put_byte(pb, 0x0d);
+ sc->iframes++;
+ } else if (pkt->pts != pkt->dts) {
+ put_byte(pb, 0x0f);
+ sc->bframes++;
+ } else {
+ put_byte(pb, 0x0e);
+ sc->pframes++;
+ }
+ put_be24(pb, size);
+ } else if (sc->codec->codec_id == CODEC_ID_DVVIDEO) {
+ put_byte(pb, size / 4096);
+ put_be24(pb, 0);
+ } else
+ put_be32(pb, size);
+ put_be32(pb, ctx->field_number);
+ put_byte(pb, 1); /* flags */
+ put_byte(pb, 0); /* reserved */
+ return 16;
+}
+
+static int gxf_write_media_packet(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt)
+{
+ GXFStreamContext *sc = &ctx->streams[pkt->stream_index];
+ offset_t pos = url_ftell(pb);
+ int padding = 0;
+
+ gxf_write_packet_header(pb, PKT_MEDIA);
+ if (sc->codec->codec_id == CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
+ padding = 4 - pkt->size % 4;
+ gxf_write_media_preamble(pb, ctx, pkt, pkt->size + padding);
+ if (sc->codec->codec_type == CODEC_TYPE_AUDIO)
+ put_buffer(pb, pkt->data, GXF_AUDIO_PACKET_SIZE);
+ else {
+ ctx->field_number += 2;
+ put_buffer(pb, pkt->data, pkt->size);
+ }
+ gxf_write_padding(pb, padding);
+ return updatePacketSize(pb, pos);
+}
+
+static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ GXFContext *gxf = s->priv_data;
+
+ gxf_write_media_packet(&s->pb, gxf, pkt);
+ put_flush_packet(&s->pb);
+ return 0;
+}
+
+static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
+{
+ AVPacketList *pktl, **next_point, *this_pktl;
+ GXFContext *gxf = s->priv_data;
+ GXFStreamContext *sc;
+ int i;
+
+ if (pkt) {
+ sc = &gxf->streams[pkt->stream_index];
+ if (sc->codec->codec_type == CODEC_TYPE_AUDIO) {
+ fifo_write(&sc->audio_buffer, pkt->data, pkt->size, NULL);
+ } else {
+ this_pktl = av_mallocz(sizeof(AVPacketList));
+ this_pktl->pkt = *pkt;
+ if(pkt->destruct == av_destruct_packet)
+ pkt->destruct = NULL; // non shared -> must keep original from being freed
+ else
+ av_dup_packet(&this_pktl->pkt); //shared -> must dup
+ next_point = &s->packet_buffer;
+ while(*next_point){
+ AVStream *st= s->streams[ pkt->stream_index];
+ AVStream *st2= s->streams[ (*next_point)->pkt.stream_index];
+ int64_t left= st2->time_base.num * (int64_t)st ->time_base.den;
+ int64_t right= st ->time_base.num * (int64_t)st2->time_base.den;
+ if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow
+ break;
+ next_point= &(*next_point)->next;
+ }
+ this_pktl->next = *next_point;
+ *next_point = this_pktl;
+ }
+ }
+
+ if (gxf->audio_written == gxf->audio_tracks) {
+ if (!s->packet_buffer) {
+ gxf->audio_written = 0;
+ return 0;
+ }
+ pktl = s->packet_buffer;
+ *out = pktl->pkt;
+ s->packet_buffer = pktl->next;
+ av_freep(&pktl);
+ return 1;
+ } else {
+ for (i = 0; i < s->nb_streams; i++) {
+ sc = &gxf->streams[i];
+ if (sc->codec->codec_type == CODEC_TYPE_AUDIO &&
+ (flush || fifo_size(&sc->audio_buffer, NULL) >= GXF_AUDIO_PACKET_SIZE)) {
+ int size = flush ? fifo_size(&sc->audio_buffer, NULL) : GXF_AUDIO_PACKET_SIZE;
+ av_new_packet(out, GXF_AUDIO_PACKET_SIZE);
+ fifo_read(&sc->audio_buffer, out->data, size, NULL);
+ gxf->audio_written++;
+ out->stream_index = i;
+ out->size = size;
+ return 1;
+ }
+ }
+ }
+ av_init_packet(out);
+ return 0;
+}
+
+AVOutputFormat gxf_muxer = {
+ "gxf",
+ "GXF format",
+ NULL,
+ "gxf",
+ sizeof(GXFContext),
+ CODEC_ID_PCM_S16LE,
+ CODEC_ID_MPEG2VIDEO,
+ gxf_write_header,
+ gxf_write_packet,
+ gxf_write_trailer,
+ 0,
+ NULL,
+ gxf_interleave_packet,
+};
2
2
r6147 - in trunk: ffplay.c libavcodec/avcodec.h libavcodec/dsputil.h libavutil/common.h
by subversion@mplayerhq.hu 01 Sep '06
by subversion@mplayerhq.hu 01 Sep '06
01 Sep '06
Author: lu_zero
Date: Thu Aug 31 21:14:00 2006
New Revision: 6147
Modified:
trunk/ffplay.c
trunk/libavcodec/avcodec.h
trunk/libavcodec/dsputil.h
trunk/libavutil/common.h
Log:
Align the input buffer in ffmpeg, introduce a public macro for it
Modified: trunk/ffplay.c
==============================================================================
--- trunk/ffplay.c (original)
+++ trunk/ffplay.c Thu Aug 31 21:14:00 2006
@@ -133,7 +133,7 @@
int audio_hw_buf_size;
/* samples output by the codec. we reserve more space for avsync
compensation */
- uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
+ DECLARE_ALIGNED(16,uint8_t,audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2]);
unsigned int audio_buf_size; /* in bytes */
int audio_buf_index; /* in bytes */
AVPacket audio_pkt;
Modified: trunk/libavcodec/avcodec.h
==============================================================================
--- trunk/libavcodec/avcodec.h (original)
+++ trunk/libavcodec/avcodec.h Thu Aug 31 21:14:00 2006
@@ -17,8 +17,8 @@
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVCODEC_VERSION_INT ((51<<16)+(11<<8)+0)
-#define LIBAVCODEC_VERSION 51.11.0
+#define LIBAVCODEC_VERSION_INT ((51<<16)+(12<<8)+0)
+#define LIBAVCODEC_VERSION 51.12.0
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
@@ -2451,6 +2451,17 @@
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
+/**
+ * Decode an audio frame.
+ *
+ * @param avctx the codec context.
+ * @param samples output buffer, 16 byte aligned
+ * @param frame_size_ptr the output buffer size in bytes, zero if no frame could be compressed
+ * @param buf input buffer, 16 byte aligned
+ * @param buf_size the input buffer size
+ * @return 0 if successful, -1 if not.
+ */
+
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size);
Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h (original)
+++ trunk/libavcodec/dsputil.h Thu Aug 31 21:14:00 2006
@@ -323,7 +323,7 @@
void (*vector_fmul_add_add)(float *dst, const float *src0, const float *src1, const float *src2, int src3, int len, int step);
/* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
- * asm versions: convert floats from [-32768.0,32767.0] without rescaling */
+ * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
void (*float_to_int16)(int16_t *dst, const float *src, int len);
/* (I)DCT */
Modified: trunk/libavutil/common.h
==============================================================================
--- trunk/libavutil/common.h (original)
+++ trunk/libavutil/common.h Thu Aug 31 21:14:00 2006
@@ -364,6 +364,13 @@
#endif
/* memory */
+
+#ifdef __GNUC__
+ #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
+#else
+ #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
+#endif
+
void *av_malloc(unsigned int size);
void *av_realloc(void *ptr, unsigned int size);
void av_free(void *ptr);
4
5
r6139 - in trunk/libavcodec: dsputil.c dsputil.h vc1.c vc1dsp.c
by subversion@mplayerhq.hu 01 Sep '06
by subversion@mplayerhq.hu 01 Sep '06
01 Sep '06
Author: kostya
Date: Thu Aug 31 06:44:54 2006
New Revision: 6139
Modified:
trunk/libavcodec/dsputil.c
trunk/libavcodec/dsputil.h
trunk/libavcodec/vc1.c
trunk/libavcodec/vc1dsp.c
Log:
New qpel MC functions conforming to VC-1 standard.
Existing DSPUtil functions cause chroma artifacts on some files.
Modified: trunk/libavcodec/dsputil.c
==============================================================================
--- trunk/libavcodec/dsputil.c (original)
+++ trunk/libavcodec/dsputil.c Thu Aug 31 06:44:54 2006
@@ -2598,6 +2598,10 @@
void ff_put_vc1_mspel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
put_pixels8_c(dst, src, stride, 8);
}
+
+void ff_put_vc1_qpel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
+ put_pixels8_c(dst, src, stride, 8);
+}
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h (original)
+++ trunk/libavcodec/dsputil.h Thu Aug 31 06:44:54 2006
@@ -396,6 +396,7 @@
* last argument is actually round value instead of height
*/
op_pixels_func put_vc1_mspel_pixels_tab[16];
+ op_pixels_func put_vc1_qpel_pixels_tab[16];
} DSPContext;
void dsputil_static_init(void);
Modified: trunk/libavcodec/vc1.c
==============================================================================
--- trunk/libavcodec/vc1.c (original)
+++ trunk/libavcodec/vc1.c Thu Aug 31 06:44:54 2006
@@ -879,13 +879,8 @@
if(s->flags & CODEC_FLAG_GRAY) return;
/* Chroma MC always uses qpel bilinear */
uvdxy = ((uvmy & 3) << 2) | (uvmx & 3);
- if(!v->rnd){
- dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
- dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
- }else{
- dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
- dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
- }
+ dsp->put_vc1_qpel_pixels_tab[uvdxy](s->dest[1], srcU, s->uvlinesize, v->rnd);
+ dsp->put_vc1_qpel_pixels_tab[uvdxy](s->dest[2], srcV, s->uvlinesize, v->rnd);
}
/** Do motion compensation for 4-MV macroblock - luminance block
@@ -1082,13 +1077,8 @@
/* Chroma MC always uses qpel bilinear */
uvdxy = ((uvmy & 3) << 2) | (uvmx & 3);
- if(!v->rnd){
- dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
- dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
- }else{
- dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
- dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
- }
+ dsp->put_vc1_qpel_pixels_tab[uvdxy](s->dest[1], srcU, s->uvlinesize, v->rnd);
+ dsp->put_vc1_qpel_pixels_tab[uvdxy](s->dest[2], srcV, s->uvlinesize, v->rnd);
}
/**
Modified: trunk/libavcodec/vc1dsp.c
==============================================================================
--- trunk/libavcodec/vc1dsp.c (original)
+++ trunk/libavcodec/vc1dsp.c Thu Aug 31 06:44:54 2006
@@ -424,6 +424,169 @@
vc1_mspel_mc(dst, src, stride, 0xF, rnd);
}
+/** Filter used to interpolate fractional pel values
+ * except for half-pel cases for _mcXY:
+ * A = (4-X)*(4-Y)
+ * B = X *(4-Y)
+ * C = (4-X)* Y
+ * D = X * Y
+ */
+#define VC1_QPEL_FILTER(src, i, stride, rnd, A, B, C, D) \
+ clip_uint8((A*src[i] + B*src[i+1] + C*src[i+stride] + D*src[i+stride+1] + 8 - rnd) >> 4)
+
+/* this one is defined in dsputil.c */
+void ff_put_vc1_qpel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
+
+static void ff_put_vc1_qpel_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 12, 4, 0, 0);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = clip_uint8((src[i] + src[i + 1] + 1 - rnd) >> 1);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc30_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 4, 12, 0, 0);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 12, 0, 4, 0);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 9, 3, 3, 1);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 6, 6, 2, 2);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc31_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 3, 9, 1, 3);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = clip_uint8((src[i] + src[i + stride] + 1 - rnd) >> 1);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 6, 2, 6, 2);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = clip_uint8((src[i] + src[i + 1] + src[i + stride] + src[i + stride + 1] + 2 - rnd) >> 2);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc32_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 2, 6, 2, 6);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc03_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 4, 0, 12, 0);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc13_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 3, 1, 9, 3);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc23_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 2, 2, 6, 6);
+ dst += stride;
+ src += stride;
+ }
+}
+
+static void ff_put_vc1_qpel_mc33_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
+ int i, j;
+ for(j = 0; j < 8; j++) {
+ for(i = 0; i < 8; i++)
+ dst[i] = VC1_QPEL_FILTER(src, i, stride, rnd, 1, 3, 3, 9);
+ dst += stride;
+ src += stride;
+ }
+}
+
void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
@@ -448,4 +611,21 @@
dsp->put_vc1_mspel_pixels_tab[13] = ff_put_vc1_mspel_mc13_c;
dsp->put_vc1_mspel_pixels_tab[14] = ff_put_vc1_mspel_mc23_c;
dsp->put_vc1_mspel_pixels_tab[15] = ff_put_vc1_mspel_mc33_c;
+
+ dsp->put_vc1_qpel_pixels_tab[ 0] = ff_put_vc1_qpel_mc00_c;
+ dsp->put_vc1_qpel_pixels_tab[ 1] = ff_put_vc1_qpel_mc10_c;
+ dsp->put_vc1_qpel_pixels_tab[ 2] = ff_put_vc1_qpel_mc20_c;
+ dsp->put_vc1_qpel_pixels_tab[ 3] = ff_put_vc1_qpel_mc30_c;
+ dsp->put_vc1_qpel_pixels_tab[ 4] = ff_put_vc1_qpel_mc01_c;
+ dsp->put_vc1_qpel_pixels_tab[ 5] = ff_put_vc1_qpel_mc11_c;
+ dsp->put_vc1_qpel_pixels_tab[ 6] = ff_put_vc1_qpel_mc21_c;
+ dsp->put_vc1_qpel_pixels_tab[ 7] = ff_put_vc1_qpel_mc31_c;
+ dsp->put_vc1_qpel_pixels_tab[ 8] = ff_put_vc1_qpel_mc02_c;
+ dsp->put_vc1_qpel_pixels_tab[ 9] = ff_put_vc1_qpel_mc12_c;
+ dsp->put_vc1_qpel_pixels_tab[10] = ff_put_vc1_qpel_mc22_c;
+ dsp->put_vc1_qpel_pixels_tab[11] = ff_put_vc1_qpel_mc32_c;
+ dsp->put_vc1_qpel_pixels_tab[12] = ff_put_vc1_qpel_mc03_c;
+ dsp->put_vc1_qpel_pixels_tab[13] = ff_put_vc1_qpel_mc13_c;
+ dsp->put_vc1_qpel_pixels_tab[14] = ff_put_vc1_qpel_mc23_c;
+ dsp->put_vc1_qpel_pixels_tab[15] = ff_put_vc1_qpel_mc33_c;
}
3
2