static void receive_video(void *param, struct video_data *frame) { profile_start(receive_video_name); struct obs_encoder *encoder = param; struct obs_encoder *pair = encoder->paired_encoder; struct encoder_frame enc_frame; if (!encoder->first_received && pair) { if (!pair->first_received || pair->first_raw_ts > frame->timestamp) { goto wait_for_audio; } } memset(&enc_frame, 0, sizeof(struct encoder_frame)); for (size_t i = 0; i < MAX_AV_PLANES; i++) { enc_frame.data[i] = frame->data[i]; enc_frame.linesize[i] = frame->linesize[i]; } if (!encoder->start_ts) encoder->start_ts = frame->timestamp; enc_frame.frames = 1; enc_frame.pts = encoder->cur_pts; do_encode(encoder, &enc_frame); encoder->cur_pts += encoder->timebase_num; wait_for_audio: profile_end(receive_video_name); }
static void receive_video(void *param, struct video_data *frame) { profile_start(receive_video_name); struct obs_encoder *encoder = param; struct encoder_frame enc_frame; memset(&enc_frame, 0, sizeof(struct encoder_frame)); for (size_t i = 0; i < MAX_AV_PLANES; i++) { enc_frame.data[i] = frame->data[i]; enc_frame.linesize[i] = frame->linesize[i]; } if (!encoder->start_ts) encoder->start_ts = frame->timestamp; enc_frame.frames = 1; enc_frame.pts = encoder->cur_pts; do_encode(encoder, &enc_frame); encoder->cur_pts += encoder->timebase_num; profile_end(receive_video_name); }
static bool enc_encode(void *data, struct encoder_frame *frame, struct encoder_packet *packet, bool *received_packet) { struct enc_encoder *enc = data; for (size_t i = 0; i < enc->audio_planes; i++) memcpy(enc->samples[i], frame->data[i], enc->frame_size_bytes); return do_encode(enc, packet, received_packet); }
bool encode(tbnet::DataBuffer *output) { output->writeInt8(compressed ? 1 : 0); if (compressed) { output->writeInt32(packet_data_len); output->writeBytes(packet_data, packet_data_len); } else { do_encode(output); } return true; }
void do_kvs_put(void *value, size_t sz) { int rc; do_encode(value, sz); #if USE_PMI2_API rc = PMI2_KVS_Put(kvs_key, kvs_value); gasneti_assert(PMI2_SUCCESS == rc); #else rc = PMI_KVS_Put(kvs_name, kvs_key, kvs_value); gasneti_assert(PMI_SUCCESS == rc); #endif }
/* Attempt to encode the test structure and compare it to custom DER */ static int do_encode_custom(EXPECTED *input, const TEST_CUSTOM_DATA *custom_data, const TEST_PACKAGE *package) { unsigned char *expected = NULL; size_t expected_length = make_custom_der(custom_data, &expected, 0); int ret; if (expected_length == 0) return -1; ret = do_encode(input, expected, expected_length, package); OPENSSL_free(expected); return ret; }
static void send_audio_data(struct obs_encoder *encoder) { struct encoder_frame enc_frame; memset(&enc_frame, 0, sizeof(struct encoder_frame)); for (size_t i = 0; i < encoder->planes; i++) { circlebuf_pop_front(&encoder->audio_input_buffer[i], encoder->audio_output_buffer[i], encoder->framesize_bytes); enc_frame.data[i] = encoder->audio_output_buffer[i]; enc_frame.linesize[i] = (uint32_t)encoder->framesize_bytes; } enc_frame.frames = (uint32_t)encoder->framesize; enc_frame.pts = encoder->cur_pts; do_encode(encoder, &enc_frame); encoder->cur_pts += encoder->framesize; }
bool compress() { // only compress once if (compressed) { return true; } bool ret = true; #ifdef WITH_COMPRESS tbnet::DataBuffer output; do_encode(&output); uint32_t raw_len = output.getDataLen(); // do compress, use snappy now ret = tair::common::compressor::do_compress (&packet_data, reinterpret_cast<uint32_t*>(&packet_data_len), output.getData(), raw_len, tair::common::data_entry::compress_type) == 0 ? true : false; if (ret) { compressed = true; } #endif 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; }
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(); } }