[FFmpeg-devel] Fwd: get_ue_golomb_31() vs. get_ue_golomb()

Monica Morogan dmonica
Thu Apr 22 23:28:47 CEST 2010


Hello everybody,

I use ffmpeg-0.5.1 to decode h264 streams and I am finding that the
next functions
ff_h264_decode_seq_parameter_set and
ff_h264_decode_picture_parameter_set

do not decode correctly the following sequence of SPS/PPS.

 00 00 00 01 27 42 80 1E 04 05 68 14 1F 90 00 00 00 01 28 04 00 80 E0 7F 20


The sps_id ( = get_ue_golomb_31()) returns 32 instead of the correct value 31.
Same when getting the sps_id from the PPS. Since 32 is out of the range (0-31).
the decoding stops.

I replaced get_ue_golomb_31 with get_ue_golomb and everything is
decoded properly.
However, get_ue_golomb_31 uses a lookup table, therefore, I would like
to know if there
is a corrected version of the table ff_ue_golomb_vlc_code[512] that I can use?
(In any case the changes I did and pasted below solved my problem).

Thanks for your time,
Monica



===================================================================
***************
*** 3727,3743 ****

     pps_id= get_ue_golomb(&s->gb);
     if(pps_id>=MAX_PPS_COUNT){
!         av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
         return -1;
     }
     if(!h0->pps_buffers[pps_id]) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
         return -1;
     }
     h->pps= *h0->pps_buffers[pps_id];

     if(!h0->sps_buffers[h->pps.sps_id]) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
         return -1;
     }
     h->sps = *h0->sps_buffers[h->pps.sps_id];
--- 3727,3743 ----

     pps_id= get_ue_golomb(&s->gb);
     if(pps_id>=MAX_PPS_COUNT){
!         av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%u) out of
range\n", pps_id);
         return -1;
     }
     if(!h0->pps_buffers[pps_id]) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS(%u)
referenced\n, pps_id");
         return -1;
     }
     h->pps= *h0->pps_buffers[pps_id];

     if(!h0->sps_buffers[h->pps.sps_id]) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS (%u)
referenced\n", h->pps.sps_id);
         return -1;
     }
     h->sps = *h0->sps_buffers[h->pps.sps_id];
***************
*** 7135,7144 ****
     get_bits1(&s->gb);   //constraint_set3_flag
     get_bits(&s->gb, 4); // reserved
     level_idc= get_bits(&s->gb, 8);
!     sps_id= get_ue_golomb_31(&s->gb);

     if(sps_id >= MAX_SPS_COUNT) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "sps_id (%d) out of
range\n", sps_id);
         return -1;
     }
     sps= av_mallocz(sizeof(SPS));
--- 7135,7150 ----
     get_bits1(&s->gb);   //constraint_set3_flag
     get_bits(&s->gb, 4); // reserved
     level_idc= get_bits(&s->gb, 8);
!
!    //sps_id= get_ue_golomb_31(&s->gb);
!   // 00 00 00 01 27 42 80 1E 04 05 68 14 1F 90 00 00 00 01 28 04 00
80 E0 7F 20
!   // get_ue_golomb_31 doesn't correctly decode the sps_id from the
!   // sequence (instead of 31 returns 32 which is out of range
!   // causing the decoding to stop
!     sps_id= get_ue_golomb(&s->gb);

     if(sps_id >= MAX_SPS_COUNT) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "sps_id (%u) out of
range\n", sps_id);
         return -1;
     }
     sps= av_mallocz(sizeof(SPS));
***************
*** 7274,7290 ****
     PPS *pps;

     if(pps_id >= MAX_PPS_COUNT) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of
range\n", pps_id);
         return -1;
     }

     pps= av_mallocz(sizeof(PPS));
     if(pps == NULL)
         return -1;
!     pps->sps_id= get_ue_golomb_31(&s->gb);

!     if((unsigned)pps->sps_id>=MAX_SPS_COUNT ||
h->sps_buffers[pps->sps_id] == NULL){
!         av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
         goto fail;
     }

--- 7280,7298 ----
     PPS *pps;

     if(pps_id >= MAX_PPS_COUNT) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%u) out of
range\n", pps_id);
         return -1;
     }

     pps= av_mallocz(sizeof(PPS));
     if(pps == NULL)
         return -1;
!
!   //pps->sps_id= get_ue_golomb_31(&s->gb);
!   pps->sps_id= get_ue_golomb(&s->gb);

!     if((unsigned)pps->sps_id>=MAX_SPS_COUNT ||
h->sps_buffers[pps->sps_id] == NULL) {
!         av_log(h->s.avctx, AV_LOG_ERROR, "pps.sps_id (%u) out of
range\n", pps->sps_id);
         goto fail;
     }

***************
*** 7433,7444 ****
     int context_count = 0;

     h->max_contexts = avctx->thread_count;
- #if 0
     int i;
!     for(i=0; i<50; i++){
!         av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
!     }
! #endif
     if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
         h->current_slice = 0;
         if (!s->first_field)
--- 7441,7448 ----
     int context_count = 0;

     h->max_contexts = avctx->thread_count;
     int i;
!
     if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
         h->current_slice = 0;
         if (!s->first_field)



More information about the ffmpeg-devel mailing list