comparison vc9.c @ 2688:97a9864010ec libavcodec

parse and save hrd_fullness and range_map
author iive
date Mon, 16 May 2005 23:11:38 +0000
parents bdd509b4b554
children 3144a4fc383b
comparison
equal deleted inserted replaced
2687:fa86fa423e92 2688:97a9864010ec
319 uint8_t buffer_size_exponent; 319 uint8_t buffer_size_exponent;
320 BitPlane ac_pred_plane; ///< AC prediction flags bitplane 320 BitPlane ac_pred_plane; ///< AC prediction flags bitplane
321 BitPlane over_flags_plane; ///< Overflags bitplane 321 BitPlane over_flags_plane; ///< Overflags bitplane
322 uint8_t condover; 322 uint8_t condover;
323 uint16_t *hrd_rate, *hrd_buffer; 323 uint16_t *hrd_rate, *hrd_buffer;
324 uint8_t *hrd_fullness;
325 uint8_t range_mapy_flag;
326 uint8_t range_mapuv_flag;
327 uint8_t range_mapy;
328 uint8_t range_mapuv;
324 //@} 329 //@}
325 #endif 330 #endif
326 } VC9Context; 331 } VC9Context;
327 332
328 /** 333 /**
459 { 464 {
460 int i, num; 465 int i, num;
461 466
462 num = 1 + get_bits(gb, 5); 467 num = 1 + get_bits(gb, 5);
463 468
469 /*hrd rate*/
464 if (v->hrd_rate || num != v->hrd_num_leaky_buckets) 470 if (v->hrd_rate || num != v->hrd_num_leaky_buckets)
465 { 471 {
466 av_freep(&v->hrd_rate); 472 av_freep(&v->hrd_rate);
467 } 473 }
468 if (!v->hrd_rate) v->hrd_rate = av_malloc(num*sizeof(uint16_t)); 474 if (!v->hrd_rate) v->hrd_rate = av_malloc(num*sizeof(uint16_t));
469 if (!v->hrd_rate) return -1; 475 if (!v->hrd_rate) return -1;
470 476
477 /*hrd buffer*/
471 if (v->hrd_buffer || num != v->hrd_num_leaky_buckets) 478 if (v->hrd_buffer || num != v->hrd_num_leaky_buckets)
472 { 479 {
473 av_freep(&v->hrd_buffer); 480 av_freep(&v->hrd_buffer);
474 } 481 }
475 if (!v->hrd_buffer) v->hrd_buffer = av_malloc(num*sizeof(uint16_t)); 482 if (!v->hrd_buffer) v->hrd_buffer = av_malloc(num*sizeof(uint16_t));
476 if (!v->hrd_buffer) return -1; 483 if (!v->hrd_buffer)
477 484 {
485 av_freep(&v->hrd_rate);
486 return -1;
487 }
488
489 /*hrd fullness*/
490 if (v->hrd_fullness || num != v->hrd_num_leaky_buckets)
491 {
492 av_freep(&v->hrd_buffer);
493 }
494 if (!v->hrd_fullness) v->hrd_fullness = av_malloc(num*sizeof(uint8_t));
495 if (!v->hrd_fullness)
496 {
497 av_freep(&v->hrd_rate);
498 av_freep(&v->hrd_buffer);
499 return -1;
500 }
478 v->hrd_num_leaky_buckets = num; 501 v->hrd_num_leaky_buckets = num;
479 502
480 //exponent in base-2 for rate 503 //exponent in base-2 for rate
481 v->bit_rate_exponent = 6 + get_bits(gb, 4); 504 v->bit_rate_exponent = 6 + get_bits(gb, 4);
482 //exponent in base-2 for buffer_size 505 //exponent in base-2 for buffer_size
661 v->hrd_param_flag = get_bits(gb, 1); 684 v->hrd_param_flag = get_bits(gb, 1);
662 if (v->hrd_param_flag) 685 if (v->hrd_param_flag)
663 { 686 {
664 if (decode_hrd(v, gb) < 0) return -1; 687 if (decode_hrd(v, gb) < 0) return -1;
665 } 688 }
689
690 /*reset scaling ranges, 6.2.2 & 6.2.3, p33*/
691 v->range_mapy_flag = 0;
692 v->range_mapuv_flag = 0;
666 693
667 av_log(avctx, AV_LOG_DEBUG, "Advanced profile not supported yet\n"); 694 av_log(avctx, AV_LOG_DEBUG, "Advanced profile not supported yet\n");
668 return -1; 695 return -1;
669 } 696 }
670 #endif 697 #endif
835 * @return Status 862 * @return Status
836 */ 863 */
837 static int advanced_entry_point_process(AVCodecContext *avctx, GetBitContext *gb) 864 static int advanced_entry_point_process(AVCodecContext *avctx, GetBitContext *gb)
838 { 865 {
839 VC9Context *v = avctx->priv_data; 866 VC9Context *v = avctx->priv_data;
840 int range_mapy_flag, range_mapuv_flag, i; 867 int i;
841 if (v->profile != PROFILE_ADVANCED) 868 if (v->profile != PROFILE_ADVANCED)
842 { 869 {
843 av_log(avctx, AV_LOG_ERROR, 870 av_log(avctx, AV_LOG_ERROR,
844 "Entry point are only defined in Advanced Profile!\n"); 871 "Entry point are only defined in Advanced Profile!\n");
845 return -1; //Only for advanced profile! 872 return -1; //Only for advanced profile!
846 } 873 }
847 if (v->hrd_param_flag) 874 if (v->hrd_param_flag)
848 { 875 {
849 //Update buffer fullness 876 //Update buffer fullness
850 av_log(avctx, AV_LOG_DEBUG, "Buffer fullness update\n"); 877 av_log(avctx, AV_LOG_DEBUG, "Buffer fullness update\n");
878 assert(v->hrd_num_leaky_buckets > 0);
851 for (i=0; i<v->hrd_num_leaky_buckets; i++) 879 for (i=0; i<v->hrd_num_leaky_buckets; i++)
852 skip_bits(gb, 8); 880 v->hrd_fullness[i] = get_bits(gb, 8);
853 } 881 }
854 if ((range_mapy_flag = get_bits(gb, 1))) 882 if ((v->range_mapy_flag = get_bits(gb, 1)))
855 { 883 {
856 //RANGE_MAPY 884 //RANGE_MAPY
857 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPY\n"); 885 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPY\n");
858 skip_bits(gb, 3); 886 v->range_mapy = get_bits(gb, 3);
859 } 887 }
860 if ((range_mapuv_flag = get_bits(gb, 1))) 888 if ((v->range_mapuv_flag = get_bits(gb, 1)))
861 { 889 {
862 //RANGE_MAPUV 890 //RANGE_MAPUV
863 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPUV\n"); 891 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPUV\n");
864 skip_bits(gb, 3); 892 v->range_mapuv = get_bits(gb, 3);
865 } 893 }
866 if (v->panscanflag) 894 if (v->panscanflag)
867 { 895 {
868 //NUMPANSCANWIN 896 //NUMPANSCANWIN
869 v->numpanscanwin = get_bits(gb, 3); 897 v->numpanscanwin = get_bits(gb, 3);