static void latm_read_ga_specific_config(int audio_object_type, MPEG4AudioConfig *c, GetBitContext *gb, PutBitContext *pb) { int ext_flag; copy_bits(pb, gb, 1); // framelen_flag if (copy_bits(pb, gb, 1)) // depends_on_coder copy_bits(pb, gb, 14); // delay ext_flag = copy_bits(pb, gb, 1); if (!c->chan_config) ff_copy_pce_data(pb, gb); // program_config_element if (audio_object_type == AOT_AAC_SCALABLE || audio_object_type == AOT_ER_AAC_SCALABLE) copy_bits(pb, gb, 3); // layer number if (!ext_flag) return; if (audio_object_type == AOT_ER_BSAC) { copy_bits(pb, gb, 5); // numOfSubFrame copy_bits(pb, gb, 11); // layer_length } else if (audio_object_type == AOT_ER_AAC_LC || audio_object_type == AOT_ER_AAC_LTP || audio_object_type == AOT_ER_AAC_SCALABLE || audio_object_type == AOT_ER_AAC_LD) copy_bits(pb, gb, 3); // stuff copy_bits(pb, gb, 1); // extflag3 }
static int latm_read_audio_specific_config(GetBitContext *gb, PutBitContext *pb) { int num_bits=0; int audio_object_type; MPEG4AudioConfig b, *c; c = &b; c->sbr = -1; audio_object_type = copy_bits(pb, gb, 5); if (audio_object_type == AOT_ESCAPE) { audio_object_type = AOT_ESCAPE + copy_bits(pb, gb, 6) + 1; } c->object_type = audio_object_type; c->sampling_index = copy_bits(pb, gb, 4); c->sample_rate = ff_mpeg4audio_sample_rates[c->sampling_index]; if (c->sampling_index == 0x0f) { c->sample_rate = copy_bits(pb, gb, 24); } c->chan_config = copy_bits(pb, gb, 4); if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) c->channels = ff_mpeg4audio_channels[c->chan_config]; if (audio_object_type == AOT_AAC_MAIN || audio_object_type == AOT_AAC_LC || audio_object_type == AOT_AAC_SSR || audio_object_type == AOT_AAC_LTP || audio_object_type == AOT_AAC_SCALABLE || audio_object_type == AOT_TWINVQ) { latm_read_ga_specific_config(audio_object_type, c, gb, pb); } else if (audio_object_type == AOT_SBR) { c->sbr = 1; c->ext_sampling_index = copy_bits(pb, gb, 4); c->ext_sample_rate = ff_mpeg4audio_sample_rates[c->ext_sampling_index]; if (c->ext_sampling_index == 0x0f) { c->ext_sample_rate = copy_bits(pb, gb, 24); } c->object_type = copy_bits(pb, gb, 5); } else if (audio_object_type >= AOT_ER_AAC_LC) { latm_read_ga_specific_config(audio_object_type, c, gb, pb); copy_bits(pb, gb, 2); // epConfig } if (c->sbr == -1 && c->sample_rate <= 24000) c->sample_rate *= 2; // count the extradata num_bits = put_bits_count(pb); flush_put_bits(pb); return num_bits; }
int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) { int five_bit_ch, four_bit_ch, comment_size, bits; int offset = put_bits_count(pb); copy_bits(pb, gb, 10); //Tag, Object Type, Frequency five_bit_ch = copy_bits(pb, gb, 4); //Front five_bit_ch += copy_bits(pb, gb, 4); //Side five_bit_ch += copy_bits(pb, gb, 4); //Back four_bit_ch = copy_bits(pb, gb, 2); //LFE four_bit_ch += copy_bits(pb, gb, 3); //Data five_bit_ch += copy_bits(pb, gb, 4); //Coupling if (copy_bits(pb, gb, 1)) //Mono Mixdown copy_bits(pb, gb, 4); if (copy_bits(pb, gb, 1)) //Stereo Mixdown copy_bits(pb, gb, 4); if (copy_bits(pb, gb, 1)) //Matrix Mixdown copy_bits(pb, gb, 3); for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16) copy_bits(pb, gb, 16); if (bits) copy_bits(pb, gb, bits); align_put_bits(pb); align_get_bits(gb); comment_size = copy_bits(pb, gb, 8); for (; comment_size > 0; comment_size--) copy_bits(pb, gb, 8); return put_bits_count(pb) - offset; }
static inline DEVICE *m_init_dev(JCR *jcr, DEVRES *device, bool new_init) { struct stat statp; int errstat; DCR *dcr = NULL; DEVICE *dev = NULL; uint32_t max_bs; Dmsg1(400, "max_block_size in device res is %u\n", device->max_block_size); /* * If no device type specified, try to guess */ if (!device->dev_type) { /* * Check that device is available */ if (stat(device->device_name, &statp) < 0) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to stat device %s: ERR=%s\n"), device->device_name, be.bstrerror()); return NULL; } if (S_ISDIR(statp.st_mode)) { device->dev_type = B_FILE_DEV; } else if (S_ISCHR(statp.st_mode)) { device->dev_type = B_TAPE_DEV; } else if (S_ISFIFO(statp.st_mode)) { device->dev_type = B_FIFO_DEV; } else if (!bit_is_set(CAP_REQMOUNT, device->cap_bits)) { Jmsg2(jcr, M_ERROR, 0, _("%s is an unknown device type. Must be tape or directory, st_mode=%x\n"), device->device_name, statp.st_mode); return NULL; } } /* * See what type of device is wanted. */ switch (device->dev_type) { /* * When using dynamic loading use the init_backend_dev() function * for any type of device not being of the type file. */ #ifndef HAVE_DYNAMIC_SD_BACKENDS #ifdef HAVE_GFAPI case B_GFAPI_DEV: dev = New(gfapi_device); break; #endif #ifdef HAVE_OBJECTSTORE case B_OBJECT_STORE_DEV: dev = New(object_store_device); break; #endif #ifdef HAVE_RADOS case B_RADOS_DEV: dev = New(rados_device); break; #endif #ifdef HAVE_CEPHFS case B_CEPHFS_DEV: dev = New(cephfs_device); break; #endif #ifdef HAVE_ELASTO case B_ELASTO_DEV: dev = New(elasto_device); break; #endif #ifdef HAVE_WIN32 case B_TAPE_DEV: dev = New(win32_tape_device); break; case B_FIFO_DEV: dev = New(win32_fifo_device); break; #else case B_TAPE_DEV: dev = New(unix_tape_device); break; case B_FIFO_DEV: dev = New(unix_fifo_device); break; #endif #endif /* HAVE_DYNAMIC_SD_BACKENDS */ #ifdef HAVE_WIN32 case B_FILE_DEV: dev = New(win32_file_device); break; #else case B_FILE_DEV: dev = New(unix_file_device); break; #endif default: #ifdef HAVE_DYNAMIC_SD_BACKENDS dev = init_backend_dev(jcr, device->dev_type); #endif break; } if (!dev) { Jmsg2(jcr, M_ERROR, 0, _("%s has an unknown device type %d\n"), device->device_name, device->dev_type); return NULL; } dev->clear_slot(); /* unknown */ /* * Copy user supplied device parameters from Resource */ dev->dev_name = get_memory(strlen(device->device_name) + 1); pm_strcpy(dev->dev_name, device->device_name); if (device->device_options) { dev->dev_options = get_memory(strlen(device->device_options) + 1); pm_strcpy(dev->dev_options, device->device_options); } dev->prt_name = get_memory(strlen(device->device_name) + strlen(device->name()) + 20); /* * We edit "Resource-name" (physical-name) */ Mmsg(dev->prt_name, "\"%s\" (%s)", device->name(), device->device_name); Dmsg1(400, "Allocate dev=%s\n", dev->print_name()); copy_bits(CAP_MAX, device->cap_bits, dev->capabilities); /* * current block sizes */ dev->min_block_size = device->min_block_size; dev->max_block_size = device->max_block_size; dev->max_volume_size = device->max_volume_size; dev->max_file_size = device->max_file_size; dev->max_concurrent_jobs = device->max_concurrent_jobs; dev->volume_capacity = device->volume_capacity; dev->max_rewind_wait = device->max_rewind_wait; dev->max_open_wait = device->max_open_wait; dev->max_open_vols = device->max_open_vols; dev->vol_poll_interval = device->vol_poll_interval; dev->max_spool_size = device->max_spool_size; dev->drive = device->drive; dev->drive_index = device->drive_index; dev->autoselect = device->autoselect; dev->norewindonclose = device->norewindonclose; dev->dev_type = device->dev_type; dev->device = device; /* * Sanity check */ if (dev->vol_poll_interval && dev->vol_poll_interval < 60) { dev->vol_poll_interval = 60; } device->dev = dev; if (dev->is_fifo()) { dev->set_cap(CAP_STREAM); /* set stream device */ } /* * If the device requires mount : * - Check that the mount point is available * - Check that (un)mount commands are defined */ if (dev->is_file() && dev->requires_mount()) { if (!device->mount_point || stat(device->mount_point, &statp) < 0) { berrno be; dev->dev_errno = errno; Jmsg2(jcr, M_ERROR_TERM, 0, _("Unable to stat mount point %s: ERR=%s\n"), device->mount_point, be.bstrerror()); } if (!device->mount_command || !device->unmount_command) { Jmsg0(jcr, M_ERROR_TERM, 0, _("Mount and unmount commands must defined for a device which requires mount.\n")); } } /* * Sanity check */ if (dev->max_block_size == 0) { max_bs = DEFAULT_BLOCK_SIZE; } else { max_bs = dev->max_block_size; } if (dev->min_block_size > max_bs) { Jmsg(jcr, M_ERROR_TERM, 0, _("Min block size > max on device %s\n"), dev->print_name()); } if (dev->max_block_size > MAX_BLOCK_LENGTH) { Jmsg3(jcr, M_ERROR, 0, _("Block size %u on device %s is too large, using default %u\n"), dev->max_block_size, dev->print_name(), DEFAULT_BLOCK_SIZE); dev->max_block_size = 0; } if (dev->max_block_size % TAPE_BSIZE != 0) { Jmsg3(jcr, M_WARNING, 0, _("Max block size %u not multiple of device %s block size=%d.\n"), dev->max_block_size, dev->print_name(), TAPE_BSIZE); } if (dev->max_volume_size != 0 && dev->max_volume_size < (dev->max_block_size << 4)) { Jmsg(jcr, M_ERROR_TERM, 0, _("Max Vol Size < 8 * Max Block Size for device %s\n"), dev->print_name()); } dev->errmsg = get_pool_memory(PM_EMSG); *dev->errmsg = 0; if ((errstat = dev->init_mutex()) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_cond_init(&dev->wait, NULL)) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_cond_init(&dev->wait_next_vol, NULL)) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_mutex_init(&dev->spool_mutex, NULL)) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init spool mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = dev->init_acquire_mutex()) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init acquire mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = dev->init_read_acquire_mutex()) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init read acquire mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } dev->set_mutex_priorities(); #ifdef xxx if ((errstat = rwl_init(&dev->lock)) != 0) { berrno be; dev->dev_errno = errstat; Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } #endif dev->clear_opened(); dev->attached_dcrs = New(dlist(dcr, &dcr->dev_link)); Dmsg2(100, "init_dev: tape=%d dev_name=%s\n", dev->is_tape(), dev->dev_name); dev->initiated = true; Dmsg3(100, "dev=%s dev_max_bs=%u max_bs=%u\n", dev->dev_name, dev->device->max_block_size, dev->max_block_size); return dev; }
/* * Start the backup of a specific file */ static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) { int status; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; /* * Save the current flags used to save the next file. */ copy_bits(FO_MAX, sp->flags, p_ctx->flags); /* * See if we start processing a new directory if so open it so the can recurse * into it if wanted. */ switch (p_ctx->type) { case FT_DIRBEGIN: /* * See if we are recursing if so we open the directory and process it. * We also open the directory when it the toplevel e.g. when p_ctx->cdir == NULL. */ if (!p_ctx->cdir || !bit_is_set(FO_NO_RECURSION, p_ctx->flags)) { /* * Change into the directory and process all entries in it. */ status = ceph_chdir(p_ctx->cmount, p_ctx->next_filename); if (status < 0) { berrno be; Jmsg(ctx, M_ERROR, "ceph_chdir(%s) failed: %s\n", p_ctx->next_filename, be.bstrerror(-status)); p_ctx->type = FT_NOOPEN; } else { /* * Push the current directory onto the directory stack so we can * continue processing it later on. */ if (p_ctx->cdir) { struct dir_stack_entry *new_entry; new_entry = (struct dir_stack_entry *)malloc(sizeof(struct dir_stack_entry)); memcpy(&new_entry->statp, &p_ctx->statp, sizeof(new_entry->statp)); new_entry->cdir = p_ctx->cdir; p_ctx->dir_stack->push(new_entry); } /* * Open this directory for processing. */ status = ceph_opendir(p_ctx->cmount, ".", &p_ctx->cdir); if (status < 0) { berrno be; Jmsg(ctx, M_ERROR, "ceph_opendir(%s) failed: %s\n", p_ctx->next_filename, be.bstrerror(-status)); p_ctx->type = FT_NOOPEN; /* * Pop the previous directory handle and continue processing that. */ if (!p_ctx->dir_stack->empty()) { struct dir_stack_entry *entry; entry = (struct dir_stack_entry *)p_ctx->dir_stack->pop(); memcpy(&p_ctx->statp, &entry->statp, sizeof(p_ctx->statp)); p_ctx->cdir = entry->cdir; free(entry); status = ceph_chdir(p_ctx->cmount, ".."); if (status < 0) { berrno be; Jmsg(ctx, M_ERROR, "ceph_chdir(..) failed: %s\n", p_ctx->next_filename, be.bstrerror(-status)); return bRC_Error; } } } else { const char *cwd; cwd = ceph_getcwd(p_ctx->cmount); pm_strcpy(p_ctx->cwd, cwd); } } } /* * No link target and read the actual content. */ sp->link = NULL; sp->no_read = true; break; case FT_DIREND: /* * For a directory, link is the same as fname, but with trailing slash * and don't read the actual content. */ Mmsg(p_ctx->link_target, "%s/", p_ctx->next_filename); sp->link = p_ctx->link_target; sp->no_read = true; break; case FT_LNK: /* * Link target and don't read the actual content. */ sp->link = p_ctx->link_target; sp->no_read = true; break; case FT_REGE: case FT_REG: case FT_SPEC: case FT_RAW: case FT_FIFO: /* * No link target and read the actual content. */ sp->link = NULL; sp->no_read = false; break; default: /* * No link target and don't read the actual content. */ sp->link = NULL; sp->no_read = true; break; } sp->fname = p_ctx->next_filename; sp->type = p_ctx->type; memcpy(&sp->statp, &p_ctx->statp, sizeof(sp->statp)); sp->save_time = p_ctx->since; /* * For Incremental and Differential backups use checkChanges method to * see if we need to backup this file. */ switch (p_ctx->backup_level) { case L_INCREMENTAL: case L_DIFFERENTIAL: switch (bfuncs->checkChanges(ctx, sp)) { case bRC_Seen: Dmsg(ctx, dbglvl, "cephfs-fd: skipping %s checkChanges returns bRC_Seen\n", p_ctx->next_filename); switch (sp->type) { case FT_DIRBEGIN: case FT_DIREND: sp->type = FT_DIRNOCHG; break; default: sp->type = FT_NOCHG; break; } break; default: break; } } return bRC_OK; }