static int vag_decode(TCModuleInstance *self, aframe_list_t *inframe, aframe_list_t *outframe) { PrivateData *pd; uint8_t *inptr; int insize; int16_t *outptr; TC_MODULE_SELF_CHECK(self, "decode"); TC_MODULE_SELF_CHECK(inframe, "decode"); TC_MODULE_SELF_CHECK(outframe, "decode"); pd = self->userdata; inptr = inframe->audio_buf; insize = inframe->audio_size; outptr = (int16_t *)outframe->audio_buf; outframe->audio_size = 0; /* Fill out any accumulated data block first */ if (pd->datalen > 0) { int needed = 16 - pd->datalen; if (insize < needed) { /* Not enough for a 16-byte block--copy and exit */ memcpy(pd->databuf + pd->datalen, inframe->audio_buf, insize); pd->datalen += insize; return TC_OK; } else { /* Finish off the partial block */ memcpy(pd->databuf + pd->datalen, inframe->audio_buf, needed); insize -= needed; do_decode(pd->databuf, outptr, 0, pd); outptr += 28; pd->datalen = 0; } } /* Loop through all complete data blocks in the input */ while (insize >= 16) { do_decode(inptr, outptr, 0, pd); inptr += 16; insize -= 16; outptr += 28; } /* Save any remaining data in the accumulation buffer */ if (insize > 0) { memcpy(pd->databuf, inptr, insize); pd->datalen = insize; } return TC_OK; }
/* exodus.codec.decode(big-endian bytes) -> list of instructions */ static PyObject *exodus_decode(PyObject *self, PyObject *args) { PyObject *arg, *insns, *insn; uint8_t *mem; Py_ssize_t sz, tsz; if (!(arg = PyTuple_GetItem(args, 0))) return NULL; if (PyBytes_AsStringAndSize(arg, (char**)&mem, &sz) < 0) return NULL; if (!(insns = PyList_New(0))) return NULL; while (sz > 0) { insn = do_decode(mem, sz, &tsz); if (insn != NULL) { if (PyList_Append(insns, insn) < 0) { Py_DECREF(insns); Py_DECREF(insn); return NULL; } } if (tsz > sz) tsz = sz; /* ??? */ sz -= tsz; mem += tsz; Py_DECREF(insn); } return insns; }
int engine_msg_process(tp_vtable_child_arg_t *c, int fd) { /* set_fl(fd, O_NONBLOCK); */ #if 0 char buffer[1024 * 1024];/* 1MB */ int rv0= -1; int rv = 0; char sessionid[67] = ""; session_gen(sessionid, sizeof(sessionid));/* 生成session id */ #endif struct engine_base *engine= NULL; tp_vtable_global_arg_t *g; g = c->global; engine = (struct engine_base *)g->consumer_arg; #if 0 for (;;) { rv0 = do_decode(fd, buffer, sizeof(buffer), msg.req, sessionid); if (rv0 == TASK_ERR || rv0 == TASK_EOF) { LOG_WARN("...do_decode:id = %s:rv0(%d) fd(%d)\n", sessionid, rv0, fd); return -1; } if (do_code(fd, buffer, sizeof(buffer), rv, msg.rsp, sessionid) == TASK_ERR) { LOG_WARN("...do_code:id =%s\n", sessionid); return -1; } } #endif return 0; }
EAC1_1_Req::EAC1_1_Req(const std::string& in) { std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true)); init(stream); self_signed = true; do_decode(); }
bool decompress() { if (!compressed) { return true; } if (NULL == packet_data || packet_data_len <= 0) { return false; } bool ret = false; #ifdef WITH_COMPRESS // TODO: redundant memcpy now, compressor can provide uncompresslen interface and // receive malloced buffer tbnet::DataBuffer input; char* raw_data = NULL; uint32_t raw_data_len = 0; ret = tair::common::compressor::do_decompress (&raw_data, &raw_data_len, packet_data, packet_data_len, tair::common::data_entry::compress_type) == 0 ? true : false; if (ret) { input.ensureFree(raw_data_len); memcpy(input.getFree(), raw_data, raw_data_len); input.pourData(raw_data_len); delete raw_data; ret = do_decode(&input); } #else log_error("decompress data but compiled without compress support"); #endif return ret; }
EAC1_1_CVC::EAC1_1_CVC(const std::string& in) { SharedPointer<DataSource> stream(new DataSource_Stream(in, true)); init(stream); self_signed = false; do_decode(); }
void do_kvs_get(void *value, size_t sz) { int rc; #if USE_PMI2_API int len; rc = PMI2_KVS_Get(kvs_name, PMI2_ID_NULL, kvs_key, kvs_value, max_val_len, &len); gasneti_assert(PMI2_SUCCESS == rc); #else rc = PMI_KVS_Get(kvs_name, kvs_key, kvs_value, max_val_len); gasneti_assert(PMI_SUCCESS == rc); #endif do_decode(value, sz); }
+EAC1_1_CVC::EAC1_1_CVC(shared_ptr<DataSource>& in) { init(in); self_signed = false; @@ -87,7 +87,7 @@ EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ EAC1_1_CVC::EAC1_1_CVC(const std::string& in) { - std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true)); + shared_ptr<DataSource> stream(new DataSource_Stream(in, true)); init(stream); self_signed = false; do_decode();
int main(int argc, char *argv[]) { int opt, optind = 0; char *tmp; struct option long_opts[] = { {"help", no_argument, 0, 'h'}, {"flags", required_argument, 0, 'f'}, {"input", required_argument, 0, 'i'}, {"output", required_argument, 0, 'o'}, {"ascii", no_argument, 0, 'a'}, {"version", no_argument, 0, 1000}, {NULL, 0, 0, 0}, }; while ((opt = getopt_long(argc, argv, "hf:i:o:a", long_opts, &optind)) != -1) { switch (opt) { case 'f': json_format_flags = strtoul(optarg, &tmp, 0); if (*tmp != '\0') { fprintf(stderr, "Bad JSON format flags: %s\n", optarg); return -1; } break; case 'i': strncpy(input_file, optarg, sizeof(input_file)); input_file_set = true; break; case 'o': strncpy(output_file, optarg, sizeof(output_file)); output_file_set = true; break; case 'a': ascii_output = true; break; case 1000: print_version(); return 0; case 'h': default: print_usage(argv[0]); return 0; } } do_decode(); return 0; }
/* Do an encode/decode round trip */ static int do_enc_dec(EXPECTED *bytes, long nbytes, const TEST_PACKAGE *package) { unsigned char *data = NULL; int len; int ret = 0; void *p = bytes; len = package->i2d(p, &data); if (len < 0) return -1; ret = do_decode(data, len, bytes, nbytes, package); OPENSSL_free(data); return ret; }
bool decode(tbnet::DataBuffer *input, tbnet::PacketHeader *header) { if (header->_dataLen < 8) { log_warn( "buffer data too few."); return false; } compressed = input->readInt8(); if (compressed) { packet_data_len = input->readInt32(); packet_data = new char[packet_data_len]; input->readBytes(packet_data, packet_data_len); } else { do_decode(input); } return true; }
static int extract_file(LHAReader *reader, char *filename, LHADecoderProgressCallback callback, void *callback_data) { FILE *fstream; char *tmp_filename = NULL; int result; // Construct filename? if (filename == NULL) { tmp_filename = full_path_for_header(reader->curr_file); if (tmp_filename == NULL) { return 0; } filename = tmp_filename; } // Create decoder. If the file cannot be created, there is no // need to even create an output file. If successful, open the // output file and decode. result = 0; if (open_decoder(reader, callback, callback_data)) { fstream = open_output_file(reader, filename); if (fstream != NULL) { result = do_decode(reader, fstream); fclose(fstream); } } // Set timestamp on file: if (result) { set_timestamps_from_header(filename, reader->curr_file); } free(tmp_filename); return result; }
GstVaapiDecoderStatus gst_vaapi_decoder_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame) { GstVaapiDecoderStatus status; g_return_val_if_fail (decoder != NULL, GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER); g_return_val_if_fail (frame != NULL, GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER); g_return_val_if_fail (frame->user_data != NULL, GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER); status = gst_vaapi_decoder_check_status (decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; return do_decode (decoder, frame); }
int lha_reader_check(LHAReader *reader, LHADecoderProgressCallback callback, void *callback_data) { if (reader->curr_file_type != CURR_FILE_NORMAL) { return 0; } // CRC checking of directories is not necessary. if (!strcmp(reader->curr_file->compress_method, LHA_COMPRESS_TYPE_DIR)) { return 1; } // Decode file. return open_decoder(reader, callback, callback_data) && do_decode(reader, NULL); }
/* Attempt to decode a custom encoding of the test structure */ static int do_decode_custom(const TEST_CUSTOM_DATA *custom_data, const EXPECTED *expected, size_t expected_size, const TEST_PACKAGE *package) { unsigned char *encoding = NULL; /* * We force the defaults to be explicitly encoded to make sure we test * for defaults that shouldn't be present (i.e. we check for failure) */ size_t encoding_length = make_custom_der(custom_data, &encoding, 1); int ret; if (encoding_length == 0) return -1; ret = do_decode(encoding, encoding_length, expected, expected_size, package); OPENSSL_free(encoding); return ret; }
int do_child(int client, int server, int encode) { esd_format_t format; int speed; char ident[ESD_NAME_MAX+1]; read(client, &format, sizeof(format)); read(client, &speed, sizeof(speed)); read(client, ident, ESD_NAME_MAX); write(server, &format, sizeof(format)); write(server, &speed, sizeof(speed)); write(server, ident, ESD_NAME_MAX); if (encode) return do_encode(client, server, format, speed, ident); else return do_decode(client, server, format, speed, ident); /* Should never get here */ return -1; }
/* ------------- init_b64bin() ------------- setup B64 (ascii) => binary table */ int b64bin(char *pIn, unsigned char *pOut) { int i,j; pData = pIn; pOutput = pOut; for(i = 0; i <= 32; i++) b64_bin[i] = 66; /* ignore controls */ for(i = 33; i < 127; i++) b64_bin[i] = 65; /* printable => inv */ for(i = 127; i <= 160; i++) b64_bin[i] = 66; /* ignore controls */ for(i = 161; i < 256; i++) b64_bin[i] = 65; /* printable => inv */ j = 0; for(i = 'A'; i <= 'Z'; i++, j++) b64_bin[i] = j; for(i = 'a'; i <= 'z'; i++, j++) b64_bin[i] = j; for(i = '0'; i <= '9'; i++, j++) b64_bin[i] = j; b64_bin['+'] = j++; b64_bin['/'] = j++; b64_bin['='] = 64; return do_decode(); }
/* * CVC Certificate Constructor */ EAC1_1_CVC::EAC1_1_CVC(SharedPointer<DataSource>& in) { init(in); self_signed = false; do_decode(); }
/* * PKCS10_Request Constructor */ PKCS10_Request::PKCS10_Request(DataSource& in) : X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST") { do_decode(); }
static GstVaapiDecoderStatus decode_step (GstVaapiDecoder * decoder) { GstVaapiParserState *const ps = &decoder->parser_state; GstVaapiDecoderStatus status; GstBuffer *buffer; gboolean got_frame; guint got_unit_size, input_size; status = gst_vaapi_decoder_check_status (decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; /* Fill adapter with all buffers we have in the queue */ for (;;) { buffer = pop_buffer (decoder); if (!buffer) break; ps->at_eos = GST_BUFFER_IS_EOS (buffer); if (!ps->at_eos) gst_adapter_push (ps->input_adapter, buffer); } /* Parse and decode all decode units */ input_size = gst_adapter_available (ps->input_adapter); if (input_size == 0) { if (ps->at_eos) return GST_VAAPI_DECODER_STATUS_END_OF_STREAM; return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA; } do { if (!ps->current_frame) { ps->current_frame = g_slice_new0 (GstVideoCodecFrame); if (!ps->current_frame) return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; ps->current_frame->ref_count = 1; ps->current_frame->system_frame_number = ps->current_frame_number++; } status = do_parse (decoder, ps->current_frame, ps->input_adapter, ps->at_eos, &got_unit_size, &got_frame); GST_DEBUG ("parse frame (status = %d)", status); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) { if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA && ps->at_eos) status = GST_VAAPI_DECODER_STATUS_END_OF_STREAM; break; } if (got_unit_size > 0) { buffer = gst_adapter_take_buffer (ps->input_adapter, got_unit_size); input_size -= got_unit_size; if (gst_adapter_available (ps->output_adapter) == 0) { ps->current_frame->pts = gst_adapter_prev_pts (ps->input_adapter, NULL); } gst_adapter_push (ps->output_adapter, buffer); } if (got_frame) { ps->current_frame->input_buffer = gst_adapter_take_buffer (ps->output_adapter, gst_adapter_available (ps->output_adapter)); status = do_decode (decoder, ps->current_frame); GST_DEBUG ("decode frame (status = %d)", status); gst_video_codec_frame_unref (ps->current_frame); ps->current_frame = NULL; break; } } while (input_size > 0); return status; }
int main(int argc, char*const* argv) { int opt, has_consumed_fmt_input; unsigned i; co_this = argv[0]; while (-1 != (opt = #ifdef HAVE_GETOPT_LONG getopt_long(argc, argv, short_options, long_options, NULL) #else getopt(argc, argv, short_options) #endif )) { switch (opt) { case '?': case ':': case 'h': fputs(usage_statement, opt == 'h'? stdout : stderr); return (opt == 'h'? 0 : 255); case 'V': puts("drachencode (" PACKAGE_STRING ")"); return 0; case 'b': uint_arg_or_die(&co_block_size, "block-size"); break; case 'd': co_is_decoding = 1; break; case 'D': co_dryrun = 1; break; case 'e': co_is_encoding = 1; break; case 'f': co_force = 1; break; case 'H': uint_arg_or_die(&co_image_bh, "img-block-height"); break; case 'W': uint_arg_or_die(&co_image_bw, "img-block-width"); break; case 'O': uint_arg_or_die(&co_image_off, "img-offset"); break; case 'C': uint_arg_or_die(&co_image_nc, "img-num-cols"); break; case 'X': uint_arg_or_die(&co_image_comps, "img-num-components"); break; case 'R': uint_arg_or_die(&co_image_nr, "img-num-rows"); break; case 'w': co_nowarn = 1; break; case 'N': co_base_son_on_output = 1; break; case 'n': co_sequential_output_name = strdup(optarg); break; case 'u': co_allow_unsafe_names = 1; break; case 'o': co_primary_filename = strdup(optarg); break; case 't': co_timing_statistics = 1; break; case 'v': ++co_verbosity; break; case 'Z': co_zero_frames = 1; break; case 'a': uint_arg_or_die(&co_begin, "begin"); break; case 'z': uint_arg_or_die(&co_end, "end"); break; case 's': uint_arg_or_die(&co_stride, "stride"); break; default: fprintf(stderr, "%s: FATAL: Unknown \"known\" option: %c\n", co_this, (char)opt); exit(255); } } /* Validate options */ if (!(co_is_decoding ^ co_is_encoding)) { l_error("Exactly one of --encode or --decode must be specified."); return 255; } if (co_is_encoding && (co_image_nc || co_image_nr || co_image_bw || co_image_bh || co_image_off || co_image_comps) && !(co_image_nc && co_image_nr && co_image_bw && co_image_bh)) { l_error("Either no image options, or at least --img-num-cols,\n" "--img-num-rows, --img-block-width, and --img-block-height\n" "must be specified."); return 255; } if (co_image_nc && !co_image_comps) co_image_comps = 1; /* Validate the format string, if given */ if (co_sequential_output_name) { has_consumed_fmt_input = 0; for (i = 0; co_sequential_output_name[i]; ++i) { if (co_sequential_output_name[i] == '%') { ++i; if (co_sequential_output_name[i] == '%') /* Simple escaped percent sign */ continue; if (has_consumed_fmt_input) { l_error("Format string has more than one consuming formatting."); return 255; } has_consumed_fmt_input = 1; /* Flags */ while (co_sequential_output_name[i] == '#' || co_sequential_output_name[i] == '0' || co_sequential_output_name[i] == '-' || co_sequential_output_name[i] == ' ' || co_sequential_output_name[i] == '+') ++i; /* Width */ while (co_sequential_output_name[i] >= '0' && co_sequential_output_name[i] <= '9') ++i; /* Type */ if (co_sequential_output_name[i] != 'd' && co_sequential_output_name[i] != 'i' && co_sequential_output_name[i] != 'o' && co_sequential_output_name[i] != 'u' && co_sequential_output_name[i] != 'x' && co_sequential_output_name[i] != 'X') { l_error("Invalid format string type."); return 255; } } } if (!has_consumed_fmt_input) { l_error("Format string is not variant."); return 255; } } if (co_is_encoding && !co_force && !co_primary_filename) { l_error("Not implicitly encoding to standard output without --force"); return 255; } if (co_image_bh && co_image_nr && co_image_nr % co_image_bh) { l_warn("img-block-height does not divide evenly into img-num-rows."); l_warn("Actual block height will differ from what you specfied."); } if (co_image_bw && co_image_nc && co_image_nc % co_image_bw) { l_warn("img-block-width does not divide evenly into img-num-cols."); l_warn("Actual block height will differ from what you specified."); } if (co_dryrun && co_is_encoding) { l_report("Changing output file to /dev/null to perform dry-run."); co_primary_filename = "/dev/null"; } if (co_is_encoding) { co_num_encoding_input_files = optind <= argc? argc - optind : 0; /* Cast is safe, we won't be modifying anything. * (char*const* -> const char*const* is technically "incompatible") */ co_encoding_input_files = (const char*const*)argv+optind; if (!co_num_encoding_input_files) { l_error("No encoding input files given."); return 255; } return do_encode(); } else { if (optind >= argc) { co_primary_filename = "-"; if (!co_force) l_warn("Decoding from standard input."); } else if (argc - optind == 1) { co_primary_filename = argv[optind]; } else { l_error("Too many input files."); return 255; } return do_decode(); } }
EAC1_1_Req::EAC1_1_Req(std::tr1::shared_ptr<DataSource> in) { init(in); self_signed = true; do_decode(); }
EAC1_1_ADO::EAC1_1_ADO(DataSource& in) { init(in); do_decode(); }
EAC1_1_ADO::EAC1_1_ADO(const std::string& in) { DataSource_Stream stream(in, true); init(stream); do_decode(); }
/* * PKCS10_Request Constructor */ PKCS10_Request::PKCS10_Request(const std::string& fsname) : X509_Object(fsname, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST") { do_decode(); }
/* * PKCS10_Request Constructor */ PKCS10_Request::PKCS10_Request(const std::vector<byte>& in) : X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST") { do_decode(); }