[Ffmpeg-devel] H.264 encoder
Panagiotis Issaris
takis.issaris
Wed Oct 11 18:00:23 CEST 2006
Hi,
On Tue, Oct 10, 2006 at 09:36:20PM +0200, Michael Niedermayer wrote:
> > > [...]
> > pred_non_zero_count() is using non_zero_count_cache, which is getting filled by
> > fill_caches() which is dependent on MpegEncContext. This makes it nearly
> > impossible to reuse this unless I pull in MpegEncContext in the H264 encoder.
> > Would that be a good idea?
>
> probably not -> change pred_non_zero_count() so it takes the top and left
> values as arguments instead of H264Context, or change it so a it takes a
> pointer to non_zero_count_cache ...
Something like the attached patch does? Or should I drop the const and move left
and top to the outer scope?
With friendly regards,
Takis
-------------- next part --------------
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 4e5e1eb..07fb893 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1110,15 +1110,12 @@ static inline void write_back_non_zero_c
* gets the predicted number of non zero coefficients.
* @param n block index
*/
-static inline int pred_non_zero_count(H264Context *h, int n){
- const int index8= scan8[n];
- const int left= h->non_zero_count_cache[index8 - 1];
- const int top = h->non_zero_count_cache[index8 - 8];
+static inline int pred_non_zero_count(H264Context *h, int left, int top){
int i= left + top;
if(i<64) i= (i+1)>>1;
- tprintf("pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31);
+ tprintf("pred_nnz L%X T%X P%X\n", left, top, i&31);
return i&31;
}
@@ -4850,11 +4847,18 @@ static int decode_residual(H264Context *
total_coeff= coeff_token>>2;
}else{
if(n == LUMA_DC_BLOCK_INDEX){
- total_coeff= pred_non_zero_count(h, 0);
+ const int left= h->non_zero_count_cache[11];
+ const int top = h->non_zero_count_cache[4];
+ total_coeff= pred_non_zero_count(h, left, top);
+ tprintf("pred_nnz L%X T%X n0 s12 P%X\n", left, top, total_coeff);
coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2);
total_coeff= coeff_token>>2;
}else{
- total_coeff= pred_non_zero_count(h, n);
+ const int index8= scan8[n];
+ const int left= h->non_zero_count_cache[index8 - 1];
+ const int top = h->non_zero_count_cache[index8 - 8];
+ total_coeff= pred_non_zero_count(h, left, top);
+ tprintf("pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], total_coeff);
coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2);
total_coeff= coeff_token>>2;
h->non_zero_count_cache[ scan8[n] ]= total_coeff;
diff --git a/libavcodec/h264cavlc.c b/libavcodec/h264cavlc.c
More information about the ffmpeg-devel
mailing list