Example #1
0
void
session_exit(session_t *sp)
{
        codec_exit();
        if (sp->local_file_player) {
                voxlet_destroy(&sp->local_file_player);
        }
	if (sp->tone_generator) {
		tonegen_destroy(&sp->tone_generator);
	}
        if (sp->in_file_converter) {
                converter_destroy(&sp->in_file_converter);
        }
	if (sp->in_file  != NULL) {
                snd_read_close (&sp->in_file);
        }
	if (sp->out_file != NULL) {
                snd_write_close(&sp->out_file);
        }
	if (sp->pdb != NULL) {
		pdb_destroy(&sp->pdb);
	}
        channel_encoder_destroy(&sp->channel_coder);
        source_list_destroy(&sp->active_sources);
	xfree(sp->mbus_engine_addr);
	xfree(sp->mbus_video_addr);
	xfree(sp->mbus_ui_addr);
	xfree(sp);
}
Example #2
0
int 
main(int argc, char *argv[])
{
        const char *codec_name, *repair_name;
        codec_id_t cid;
        repair_id_t rid;
        struct s_sndfile *sf_in = NULL, *sf_out = NULL;
        sndfile_fmt_t     sff;
        double drop = 0.0;
        int ac, did_query = FALSE;
        int csra  = TRUE; /* codec specific repair allowed */
        long seed = 100;

        codec_init();

        ac = 1;
        while(ac < argc && argv[ac][0] == '-') {
                if (strlen(argv[ac]) > 2) {
                        /* should be -codecs or -repairs */
                        switch(argv[ac][1]) {
                        case 'c':
                                list_codecs();
                                break;
                        case 'r':
                                list_repairs(); 
                                break;
                        default:
                                usage();
                        }
                        did_query = TRUE;
                } else {
                        if (argc - ac < 1) {
                                usage();
                        } 
                        switch(argv[ac][1]) {
                        case 's':
                                seed = atoi(argv[++ac]);
                                break;
                        case 'd':
                                drop = strtod(argv[++ac], NULL);
                                break;
                        case 'c':
                                cid  = codec_get_by_name(argv[++ac]);
                                codec_name = argv[ac];
                                break;
                        case 'n':
                                csra = FALSE;
                                break;
                        case 'r':
                                resolve_repair(argv[++ac], &rid, &repair_name);
                                break;
                        case 'u':
                                units_per_packet = atoi(argv[++ac]);
                                break;
                        default:
                                usage();
                        }
                }
                ac++;
        }
        
        if (did_query == TRUE) {
                /* Not sensible to be running query and executing test */
                exit(-1);
        }

        if (argc - ac != 2) {
                usage();
        }


        if (snd_read_open(&sf_in, argv[ac], NULL) == FALSE) {
                fprintf(stderr, "Could not open %s\n", argv[ac]);
                exit(-1);
        }
        ac++;

        if (snd_get_format(sf_in, &sff) == FALSE) {
                fprintf(stderr, "Failed to get format of %s\n", argv[ac]);
                exit(-1);
        }

        if (snd_write_open(&sf_out, argv[ac], "au", &sff) == FALSE) {
                fprintf(stderr, "Could not open %s\n", argv[ac]);
                exit(-1);
        }

        if (file_and_codec_compatible(&sff, cid) == FALSE) {
                fprintf(stderr, "Codec and file type are not compatible\n");
                exit(-1);
        }

        printf("# Parameters
#\tseed: %ld
#\tdrop: %.2f
#\tcodec:  %s
#\tunits per packet: %d
#\trepair: %s
#\tcodec specific repair (when available): %d
#\tsource file: %s
#\tdestination file %s\n",
seed, drop, codec_name, units_per_packet, repair_name, csra, argv[argc - 2], argv[argc - 1]);

	repair_set_codec_specific_allowed(csra);

	init_drop(seed, drop);
        test_repair(sf_out, cid, rid, sf_in);

        /* snd_read_close(&sf_in) not needed because files gets closed
         * at eof automatically. 
         */
        snd_write_close(&sf_out);

        codec_exit();
        xmemdmp();

        return 0;
}
Example #3
0
void allocate_input(app_ctxt_t *ps_app_ctxt)
{

    WORD32 num_bufs;
    WORD32 pic_size;
    WORD32 luma_size;
    WORD32 chroma_size;
    WORD32 num_mbs;
    WORD32 i;
    UWORD8 *pu1_buf[3];

    ih264e_ctl_getbufinfo_op_t *ps_get_buf_info_op = &ps_app_ctxt->s_get_buf_info_op;

    num_bufs = MAX(DEFAULT_NUM_INPUT_BUFS, ps_get_buf_info_op->s_ive_op.u4_min_inp_bufs);
    num_bufs = MIN(DEFAULT_MAX_INPUT_BUFS, num_bufs);

    /* Size of buffer */
    luma_size = ps_app_ctxt->u4_wd * ps_app_ctxt->u4_ht;
    chroma_size = luma_size >> 1;
    pic_size = luma_size + chroma_size;

    num_mbs = ALIGN16(ps_app_ctxt->u4_max_wd) *  ALIGN16(ps_app_ctxt->u4_max_ht);
    num_mbs /= 256;

    /* Memset the input buffer array to set is_free to 0 */
    memset(ps_app_ctxt->as_input_buf, 0, sizeof(input_buf_t) * DEFAULT_MAX_INPUT_BUFS);

    for(i = 0; i < num_bufs; i++)
    {
        pu1_buf[0] = (UWORD8 *)ih264a_aligned_malloc(16, pic_size);
        if(NULL == pu1_buf[0])
        {
            CHAR ac_error[STRLENGTH];
            sprintf(ac_error, "Allocation failed for input buffer of size %d\n",
                    pic_size);
            codec_exit(ac_error);
        }
        ps_app_ctxt->as_input_buf[i].pu1_buf = pu1_buf[0];

        pu1_buf[0] = (UWORD8 *)ih264a_aligned_malloc(16, num_mbs * sizeof(ih264e_mb_info_t));
        if(NULL == pu1_buf[0])
        {
            CHAR ac_error[STRLENGTH];
            sprintf(ac_error, "Allocation failed for mb info buffer of size %d\n",
                    (WORD32)(num_mbs * sizeof(ih264e_mb_info_t)));
            codec_exit(ac_error);
        }
        ps_app_ctxt->as_input_buf[i].pv_mb_info = pu1_buf[0];
        pu1_buf[0] = (UWORD8 *)ih264a_aligned_malloc(16, sizeof(ih264e_pic_info2_t));
        if(NULL == pu1_buf[0])
        {
            CHAR ac_error[STRLENGTH];
            sprintf(ac_error, "Allocation failed for pic info buffer of size %d\n",
                   (WORD32) sizeof(ih264e_pic_info2_t));
            codec_exit(ac_error);
        }
        ps_app_ctxt->as_input_buf[i].pv_pic_info = pu1_buf[0];
        ps_app_ctxt->as_input_buf[i].u4_buf_size = pic_size;
        ps_app_ctxt->as_input_buf[i].u4_is_free = 1;
    }
    return;
}