MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Encode

Function Encode

tensorflow/contrib/ffmpeg/encode_audio_op.cc:31–49  ·  view source on GitHub ↗

* Encoding implementation, shared across V1 and V2 ops. Creates a new * output in the context. */

Source from the content-addressed store, hash-verified

29 * output in the context.
30 */
31void Encode(OpKernelContext* context, const Tensor& contents,
32 const string& file_format, const int32 bits_per_second,
33 const int32 samples_per_second) {
34 std::vector<float> samples;
35 samples.reserve(contents.NumElements());
36 for (int32 i = 0; i < contents.NumElements(); ++i) {
37 samples.push_back(contents.flat<float>()(i));
38 }
39 const int32 channel_count = contents.dim_size(1);
40 string encoded_audio;
41 OP_REQUIRES_OK(
42 context, CreateAudioFile(file_format, bits_per_second, samples_per_second,
43 channel_count, samples, &encoded_audio));
44
45 // Copy the encoded audio file to the output tensor.
46 Tensor* output = nullptr;
47 OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape(), &output));
48 output->scalar<tstring>()() = encoded_audio;
49}
50
51} // namespace
52

Callers 2

ComputeMethod · 0.70
ComputeMethod · 0.70

Calls 7

CreateAudioFileFunction · 0.85
allocate_outputMethod · 0.80
TensorShapeClass · 0.50
reserveMethod · 0.45
NumElementsMethod · 0.45
push_backMethod · 0.45
dim_sizeMethod · 0.45

Tested by

no test coverage detected