00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "global.h"
00016 #include "nalu.h"
00017 #include "nal.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 int RBSPtoNALU (unsigned char *rbsp, NALU_t *nalu, int rbsp_size, int nal_unit_type, int nal_reference_idc,
00045 int min_num_bytes, int UseAnnexbLongStartcode)
00046 {
00047 int len;
00048
00049 assert (nalu != NULL);
00050 assert (nal_reference_idc <=3 && nal_reference_idc >=0);
00051 assert (nal_unit_type > 0 && nal_unit_type <= 10);
00052 assert (rbsp_size < MAXRBSPSIZE);
00053
00054 nalu->startcodeprefix_len = UseAnnexbLongStartcode ? 4 : 3;
00055 nalu->forbidden_bit = 0;
00056 nalu->nal_reference_idc = (NalRefIdc) nal_reference_idc;
00057 nalu->nal_unit_type = (NaluType) nal_unit_type;
00058
00059 len = RBSPtoEBSP (nalu->buf, rbsp, rbsp_size);
00060 nalu->len = len;
00061
00062 return len;
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072 int Write_AUD_NALU( void )
00073 {
00074 int RBSPlen = 0;
00075 int NALUlen, len;
00076 byte rbsp[MAXRBSPSIZE];
00077 NALU_t *nalu = AllocNALU( 64000 );
00078
00079 switch( img->type )
00080 {
00081 case I_SLICE:
00082 img->primary_pic_type = 0;
00083 break;
00084 case P_SLICE:
00085 img->primary_pic_type = 1;
00086 break;
00087 case B_SLICE:
00088 img->primary_pic_type = 2;
00089 break;
00090 }
00091 RBSPlen = 1;
00092 rbsp[0] = img->primary_pic_type << 5;
00093 rbsp[0] |= (1 << 4);
00094
00095
00096 NALUlen = RBSPtoNALU( rbsp, nalu, RBSPlen, NALU_TYPE_AUD, NALU_PRIORITY_HIGHEST, 0, 1 );
00097
00098 len = WriteNALU( nalu );
00099
00100 FreeNALU( nalu );
00101
00102 return len;
00103 }