static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc) { avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */ avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */ avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */ avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */ avio_wl32(pb, 0); /* reserved */ avio_wl32(pb, 0); /* reserved */ return 32; }
static int gxf_write_umf_media_audio(ByteIOContext *pb, GXFStreamContext *track) { put_le64(pb, av_dbl2int(1)); /* sound level to begin to */ put_le64(pb, av_dbl2int(1)); /* sound level to begin to */ put_le32(pb, 0); /* number of fields over which to ramp up sound level */ put_le32(pb, 0); /* number of fields over which to ramp down sound level */ put_le32(pb, 0); /* reserved */ put_le32(pb, 0); /* reserved */ return 32; }
static void put_amf_double( ByteIOContext *pb, double d ) { LogStr("Init"); put_byte(pb, AMF_DATA_TYPE_NUMBER); put_be64(pb, av_dbl2int(d)); LogStr("Exit"); }
static int sox_write_header(AVFormatContext *s) { SoXContext *sox = s->priv_data; ByteIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; AVMetadataTag *comment; size_t comment_len = 0, comment_size; comment = av_metadata_get(s->metadata, "comment", NULL, 0); if (comment) comment_len = strlen(comment->value); comment_size = (comment_len + 7) & ~7; sox->header_size = SOX_FIXED_HDR + comment_size; if (enc->codec_id == CODEC_ID_PCM_S32LE) { put_tag(pb, ".SoX"); put_le32(pb, sox->header_size); put_le64(pb, 0); /* number of samples */ put_le64(pb, av_dbl2int(enc->sample_rate)); put_le32(pb, enc->channels); put_le32(pb, comment_size); } else if (enc->codec_id == CODEC_ID_PCM_S32BE) { put_tag(pb, "XoS."); put_be32(pb, sox->header_size); put_be64(pb, 0); /* number of samples */ put_be64(pb, av_dbl2int(enc->sample_rate)); put_be32(pb, enc->channels); put_be32(pb, comment_size); } else { av_log(s, AV_LOG_ERROR, "invalid codec; use pcm_s32le or pcm_s32be\n"); return -1; } if (comment_len) put_buffer(pb, comment->value, comment_len); for ( ; comment_size > comment_len; comment_len++) put_byte(pb, 0); put_flush_packet(pb); return 0; }
static int ffm_write_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; ByteIOContext *pb = s->pb; AVCodecContext *codec; int bit_rate, i; ffm->packet_size = FFM_PACKET_SIZE; /* header */ put_le32(pb, MKTAG('F', 'F', 'M', '1')); put_be32(pb, ffm->packet_size); /* XXX: store write position in other file ? */ put_be64(pb, ffm->packet_size); /* current write position */ put_be32(pb, s->nb_streams); bit_rate = 0; for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; bit_rate += st->codec->bit_rate; } put_be32(pb, bit_rate); /* list of streams */ for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; av_set_pts_info(st, 64, 1, 1000000); codec = st->codec; /* generic info */ put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); put_be32(pb, codec->bit_rate); put_be32(pb, st->quality); put_be32(pb, codec->flags); put_be32(pb, codec->flags2); put_be32(pb, codec->debug); /* specific info */ switch(codec->codec_type) { case CODEC_TYPE_VIDEO: put_be32(pb, codec->time_base.num); put_be32(pb, codec->time_base.den); put_be16(pb, codec->width); put_be16(pb, codec->height); put_be16(pb, codec->gop_size); put_be32(pb, codec->pix_fmt); put_byte(pb, codec->qmin); put_byte(pb, codec->qmax); put_byte(pb, codec->max_qdiff); put_be16(pb, (int) (codec->qcompress * 10000.0)); put_be16(pb, (int) (codec->qblur * 10000.0)); put_be32(pb, codec->bit_rate_tolerance); put_strz(pb, codec->rc_eq ? codec->rc_eq : "tex^qComp"); put_be32(pb, codec->rc_max_rate); put_be32(pb, codec->rc_min_rate); put_be32(pb, codec->rc_buffer_size); put_be64(pb, av_dbl2int(codec->i_quant_factor)); put_be64(pb, av_dbl2int(codec->b_quant_factor)); put_be64(pb, av_dbl2int(codec->i_quant_offset)); put_be64(pb, av_dbl2int(codec->b_quant_offset)); put_be32(pb, codec->dct_algo); put_be32(pb, codec->strict_std_compliance); put_be32(pb, codec->max_b_frames); put_be32(pb, codec->luma_elim_threshold); put_be32(pb, codec->chroma_elim_threshold); put_be32(pb, codec->mpeg_quant); put_be32(pb, codec->intra_dc_precision); put_be32(pb, codec->me_method); put_be32(pb, codec->mb_decision); put_be32(pb, codec->nsse_weight); put_be32(pb, codec->frame_skip_cmp); put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity)); put_be32(pb, codec->codec_tag); put_byte(pb, codec->thread_count); break; case CODEC_TYPE_AUDIO: put_be32(pb, codec->sample_rate); put_le16(pb, codec->channels); put_le16(pb, codec->frame_size); break; default: return -1; } if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { put_be32(pb, codec->extradata_size); put_buffer(pb, codec->extradata, codec->extradata_size); } } /* flush until end of block reached */ while ((url_ftell(pb) % ffm->packet_size) != 0) put_byte(pb, 0); put_flush_packet(pb); /* init packet mux */ ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE; assert(ffm->packet_end >= ffm->packet); ffm->frame_offset = 0; ffm->dts = 0; ffm->first_packet = 1; return 0; }
void ff_amf_write_number(uint8_t **dst, double val) { bytestream_put_byte(dst, AMF_DATA_TYPE_NUMBER); bytestream_put_be64(dst, av_dbl2int(val)); }
static void put_amf_double(AVIOContext *pb, double d) { avio_w8(pb, AMF_DATA_TYPE_NUMBER); avio_wb64(pb, av_dbl2int(d)); }
static int caf_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; CAFContext *caf = s->priv_data; unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id); switch (enc->codec_id) { case CODEC_ID_AAC: case CODEC_ID_AC3: av_log(s, AV_LOG_ERROR, "muxing codec currently unsupported\n"); return AVERROR_PATCHWELCOME; } switch (enc->codec_id) { case CODEC_ID_PCM_S8: case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24BE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: codec_tag = MKTAG('l','p','c','m'); } if (!codec_tag) { av_log(s, AV_LOG_ERROR, "unsupported codec\n"); return AVERROR_INVALIDDATA; } if (!enc->block_align && !pb->seekable) { av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n"); return AVERROR_INVALIDDATA; } ffio_wfourcc(pb, "caff"); //< mFileType avio_wb16(pb, 1); //< mFileVersion avio_wb16(pb, 0); //< mFileFlags ffio_wfourcc(pb, "desc"); //< Audio Description chunk avio_wb64(pb, 32); //< mChunkSize avio_wb64(pb, av_dbl2int(enc->sample_rate)); //< mSampleRate avio_wl32(pb, codec_tag); //< mFormatID avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags avio_wb32(pb, enc->block_align); //< mBytesPerPacket avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket avio_wb32(pb, enc->channels); //< mChannelsPerFrame avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel if (enc->channel_layout) { ffio_wfourcc(pb, "chan"); avio_wb64(pb, 12); ff_mov_write_chan(pb, enc->channel_layout); } if (enc->codec_id == CODEC_ID_ALAC) { ffio_wfourcc(pb, "kuki"); avio_wb64(pb, 12 + enc->extradata_size); avio_write(pb, "\0\0\0\14frmaalac", 12); avio_write(pb, enc->extradata, enc->extradata_size); } else if (enc->codec_id == CODEC_ID_AMR_NB) { ffio_wfourcc(pb, "kuki"); avio_wb64(pb, 29); avio_write(pb, "\0\0\0\14frmasamr", 12); avio_wb32(pb, 0x11); /* size */ avio_write(pb, "samrFFMP", 8); avio_w8(pb, 0); /* decoder version */ avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */ avio_w8(pb, 0x00); /* Mode change period (no restriction) */ avio_w8(pb, 0x01); /* Frames per sample */ } else if (enc->codec_id == CODEC_ID_QDM2) { ffio_wfourcc(pb, "kuki"); avio_wb64(pb, enc->extradata_size); avio_write(pb, enc->extradata, enc->extradata_size); } ffio_wfourcc(pb, "data"); //< Audio Data chunk caf->data = avio_tell(pb); avio_wb64(pb, -1); //< mChunkSize avio_wb32(pb, 0); //< mEditCount avio_flush(pb); return 0; }
static void put_amf_double(ByteIOContext *pb, double d) { put_byte(pb, AMF_DOUBLE); put_be64(pb, av_dbl2int(d)); }