valgrind issue for help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



  I am not so familiar with the buffer handling.  Maybe the following codes related? 
Who cam  take a moment help me to find it out.My project is blocked by it. Thanks
if (gst_structure_has_field(structure, "codec_data")) {
    extra_data_buf = (GValue *) gst_structure_get_value(structure, "codec_data");

if (extra_data_buf) {
    info->configdata = gst_buffer_copy(gst_value_get_buffer(extra_data_buf));
			AML_DUMP_BUFFER(info->configdata, "Audio Codec Data");
    }
}
====================
int extract_adts_header(StreamInfo *info,codec_para_t *pcodec, GstBuffer *buffer)
{
	adts_header_t hdr;
	guint8 *p = NULL;
	guint8 *buf;
	GstMapInfo map;
	if (info->configdata) {
		gst_buffer_map(info->configdata, &map, GST_MAP_READ);
		p = map.data;
		hdr.profile = "" >> 3) - 1;                  
		hdr.sample_freq_idx = (*p & 0x7) << 1 | (*(p + 1) >> 7);                    
		hdr.channel_configuration = (*(p + 1) & 0x7f) >> 3;                    
		gst_buffer_unmap(info->configdata, &map);
	} else {
		return 0;
	}

	hdr.syncword = 0xfff;
	hdr.id = 0;
	hdr.layer = 0;
	hdr.protection_absent = 1;
	hdr.private_bit = 0;
	hdr.original_copy = 0;
	hdr.home = 0;
	hdr.copyright_identification_bit = 0;
	hdr.copyright_identification_start = 0;
	hdr.aac_frame_length = 0;
	hdr.adts_buffer_fullness = 0x7ff;

	gst_buffer_map(buffer, &map, GST_MAP_WRITE);
	buf = map.data;
	if (buf) {
		buf[0] = (char) (hdr.syncword >> 4);
		buf[1] = (char) ((hdr.syncword & 0xf << 4) ;
		buf[2] = (char) ((hdr.profile << 6) ;
		buf[3] = (char) (((hdr.channel_configuration & 0x3) << 6));
		buf[4] = (char) ((hdr.aac_frame_length >> 3) & 0xff);
		buf[5] = (char) (((hdr.aac_frame_length & 0x7) << 5);
		buf[6] = (char) (((hdr.adts_buffer_fullness & 0x3f) << 2);
		
		gst_buffer_unmap(buffer, &map);

		gst_buffer_unref(info->configdata);
		
		info->configdata = gst_buffer_copy(buffer);

		gst_buffer_set_size(info->configdata, ADTS_HEADER_SIZE);


	} else {		
		return -1;
	}

	return 0;
}
=================================
gint adts_startcode(StreamInfo* info, codec_para_t *pcodec, GstBuffer *buffer)
{
    gint8 *buf ;
    int i;
    int size = ADTS_HEADER_SIZE + gst_buffer_get_size(buffer);   // 13bit valid
    size &= 0x1fff;
    guint8 *adts_header=NULL;
    GstBuffer *buffer1;
    GstMapInfo map;
    if (!info->configdata) {
    	return 0;
    }

    while (buffer&&gst_buffer_get_size(buffer)>=ADTS_HEADER_SIZE) {
        buffer1 = gst_buffer_new_and_alloc(ADTS_HEADER_SIZE);
        if (buffer1) {
        	gst_buffer_copy_into(buffer1, buffer, GST_BUFFER_COPY_DEEP, 0, ADTS_HEADER_SIZE);
        	gst_buffer_map(buffer1, &map, GST_MAP_READ);
        	adts_header=map.data;
        	//gst_buffer_unmap(buffer1, &map);
			
		if (((adts_header[0] << 4) != 0xFFF)     
			break;
		if (((*(adts_header + 4) & 0xFF) << 3))    
			break;
		}
		else  break;
        GST_WARNING(" AAC es has adts header,don't add again");
        
        gst_buffer_unmap(buffer1, &map);
        if(adts_header){
            gst_buffer_unref(buffer1);
             buffer1=NULL;
        }		
        return 0; 
    }


    if(adts_header){
        gst_buffer_unmap(buffer1, &map);	
        gst_buffer_unref(buffer1);
        buffer1=NULL;
    }
	
    gst_buffer_map(info->configdata, &map, GST_MAP_WRITE);
	  buf = map.data;
    if (buf!=NULL) {
        buf[3] = (buf[3] & 0xfc) | (size >> 11);
        buf[4] = (size >> 3) & 0xff;
        buf[5] = ((size & 0x7) << 5);
        
        if ( gst_buffer_get_size(info->configdata) == ADTS_HEADER_SIZE) {
            codec_write(pcodec,buf,gst_buffer_get_size(info->configdata));
	        }
    }
	  gst_buffer_unmap(info->configdata, &map);

    return 0;
}
_______________________________________________
gstreamer-embedded mailing list
gstreamer-embedded@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/gstreamer-embedded

[Index of Archives]     [Linux Embedded]     [Linux ARM Kernel]     [Linux for ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux Media]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux