Lines Matching defs:stream
74 /* stream info */
141 /* maximum bit rate of the multiplexed stream */
145 /* This header applies only to the video stream
172 /* This header applies only to the audio stream
185 * id (0xB9) video, maximum P-STD for stream 0xE0. (P-STD_buffer_bound_scale = 1)
187 * id (0xBD) private stream 1 (audio other than MPEG and subpictures). (P-STD_buffer_bound_scale = 1)
188 * id (0xBF) private stream 2, NAV packs, set to 2x1024. */
196 StreamInfo *stream = ctx->streams[i]->priv_data;
198 id = stream->id;
199 if (id == 0xbd && stream->max_buffer_size > P_STD_max_mpeg_PS1) {
200 P_STD_max_mpeg_PS1 = stream->max_buffer_size;
202 stream->max_buffer_size > P_STD_max_mpeg_audio) {
203 P_STD_max_mpeg_audio = stream->max_buffer_size;
205 stream->max_buffer_size > P_STD_max_video) {
206 P_STD_max_video = stream->max_buffer_size;
211 put_bits(&pb, 8, 0xb9); /* stream ID */
219 put_bits(&pb, 8, 0xb8); /* stream ID */
224 /* private stream 1 */
225 put_bits(&pb, 8, 0xbd); /* stream ID */
230 /* private stream 2 */
231 put_bits(&pb, 8, 0xbf); /* stream ID */
236 /* audio stream info */
239 StreamInfo *stream = ctx->streams[i]->priv_data;
241 /* For VCDs, only include the stream info for the stream
244 if (!s->is_vcd || stream->id == only_for_stream_id ||
246 id = stream->id;
254 put_bits(&pb, 8, id); /* stream ID */
259 put_bits(&pb, 13, stream->max_buffer_size / 128);
263 put_bits(&pb, 13, stream->max_buffer_size / 1024);
280 StreamInfo *stream;
289 stream = ctx->streams[i]->priv_data;
290 if (stream->id < 0xc0) {
305 StreamInfo *stream;
347 stream = av_mallocz(sizeof(StreamInfo));
348 if (!stream)
350 st->priv_data = stream;
364 "to force a MPEG-2 program stream.\n",
367 stream->id = ac3_id++;
369 stream->id = dts_id++;
371 stream->id = lpcm_id++;
378 av_log(ctx, AV_LOG_ERROR, "Invalid sampling rate for PCM stream.\n");
389 stream->lpcm_header[0] = 0x0c;
390 stream->lpcm_header[1] = (st->codecpar->ch_layout.nb_channels - 1) | (j << 4);
391 stream->lpcm_header[2] = 0x80;
392 stream->lpcm_align = st->codecpar->ch_layout.nb_channels * 2;
406 stream->lpcm_header[0] = 0x0c;
407 stream->lpcm_header[1] = (freq << 4) |
410 stream->lpcm_header[2] = 0x80;
411 stream->id = lpcm_id++;
412 stream->lpcm_align = st->codecpar->ch_layout.nb_channels * st->codecpar->bits_per_coded_sample / 8;
424 stream->id = mpa_id++;
429 stream->max_buffer_size = 4 * 1024;
434 stream->id = h264_id++;
436 stream->id = mpv_id++;
440 stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8;
447 stream->max_buffer_size = 230 * 1024;
449 if (stream->max_buffer_size > 1024 * 8191) {
450 av_log(ctx, AV_LOG_WARNING, "buffer size %d, too large\n", stream->max_buffer_size);
451 stream->max_buffer_size = 1024 * 8191;
456 stream->id = mps_id++;
457 stream->max_buffer_size = 16 * 1024;
460 av_log(ctx, AV_LOG_ERROR, "Invalid media type %s for output stream #%d\n",
464 stream->fifo = av_fifo_alloc2(16, 1, 0);
465 if (!stream->fifo)
475 stream = (StreamInfo *)st->priv_data;
488 if ((stream->id & 0xe0) == AUDIO_ID)
520 /* The VCD standard states that the muxed stream must be
553 * in the whole file: one in the first packet of each stream.
560 stream = ctx->streams[i]->priv_data;
561 stream->packet_number = 0;
576 * the multiplexed stream. */
592 * can occur if another stream has already advanced further. */
616 static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len)
619 PacketDesc *pkt_desc = stream->premux_packet;
637 /* flush the packet on stream stream_index */
642 StreamInfo *stream = ctx->streams[stream_index]->priv_data;
650 /* "general" pack without data specific to one stream? */
654 id = stream->id;
667 /* there is exactly one system header for each stream in a VCD MPEG,
671 if (stream->packet_number == 0) {
676 if (stream->align_iframe || s->packet_number == 0) {
686 if (stream->bytes_to_iframe == 0 || s->packet_number == 0) {
705 stream->align_iframe = 0;
713 } else if (stream->bytes_to_iframe < PES_bytes_to_fill) {
715 stream->bytes_to_iframe;
735 if ((s->is_vcd && stream->packet_number == 0) ||
737 /* for VCD the first pack of each stream contains only the pack header,
744 /* the system header refers to both streams and no stream data */
759 if (stream->packet_number == 0)
788 stuffing_size = payload_size - av_fifo_can_read(stream->fifo);
800 if (s->is_dvd && stream->align_iframe) {
826 if (payload_size < av_fifo_can_read(stream->fifo))
827 stuffing_size += payload_size % stream->lpcm_align;
837 nb_frames = get_nb_frames(ctx, stream, payload_size - stuffing_size);
859 * every stream. (see SVCD standard p. 26 V.2.3.1 and V.2.3.2
861 if (stream->packet_number == 0)
877 avio_wb16(ctx->pb, 0x4000 | stream->max_buffer_size / 128);
879 avio_wb16(ctx->pb, 0x6000 | stream->max_buffer_size / 1024);
908 avio_w8(ctx->pb, stream->lpcm_header[0]);
909 avio_w8(ctx->pb, stream->lpcm_header[1]);
910 avio_w8(ctx->pb, stream->lpcm_header[2]);
920 av_assert0(fifo_data <= av_fifo_can_read(stream->fifo));
921 av_fifo_read_to_cb(stream->fifo, fifo_avio_wrapper, ctx->pb, &fifo_data);
922 stream->bytes_to_iframe -= fifo_data;
937 /* only increase the stream packet number if this pack actually contains
938 * something that is specific to this stream! I.e. a dedicated header
941 stream->packet_number++;
975 StreamInfo *stream = st->priv_data;
978 while ((pkt_desc = stream->predecode_packet) &&
980 if (stream->buffer_index < pkt_desc->size ||
981 stream->predecode_packet == stream->premux_packet) {
984 i, stream->buffer_index, pkt_desc->size);
987 stream->buffer_index -= pkt_desc->size;
988 stream->predecode_packet = pkt_desc->next;
989 if (!stream->predecode_packet)
990 stream->last_packet = NULL;
1002 StreamInfo *stream;
1015 StreamInfo *stream = st->priv_data;
1016 const size_t avail_data = av_fifo_can_read(stream->fifo);
1017 const int space = stream->max_buffer_size - stream->buffer_index;
1018 int rel_space = 1024LL * space / stream->max_buffer_size;
1019 PacketDesc *next_pkt = stream->premux_packet;
1035 if ( stream->predecode_packet
1036 && stream->predecode_packet->size > stream->buffer_index)
1051 StreamInfo *stream = st->priv_data;
1052 PacketDesc *pkt_desc = stream->predecode_packet;
1055 has_premux |= !!stream->premux_packet;
1084 stream = st->priv_data;
1086 av_assert0(av_fifo_can_read(stream->fifo) > 0);
1090 timestamp_packet = stream->premux_packet;
1099 av_log(ctx, AV_LOG_TRACE, "dts:%f pts:%f scr:%f stream:%d\n",
1106 av_assert0(av_fifo_can_read(stream->fifo) == trailer_size);
1117 while ((vcd_pad_bytes = get_vcd_padding_size(ctx, stream->premux_packet->pts)) >= s->packet_size) {
1124 stream->buffer_index += es_size;
1128 while (stream->premux_packet &&
1129 stream->premux_packet->unwritten_size <= es_size) {
1130 es_size -= stream->premux_packet->unwritten_size;
1131 stream->premux_packet = stream->premux_packet->next;
1134 av_assert0(stream->premux_packet);
1135 stream->premux_packet->unwritten_size -= es_size;
1151 StreamInfo *stream = st->priv_data;
1180 av_log(ctx, AV_LOG_TRACE, "dts:%f pts:%f flags:%d stream:%d nopts:%d\n",
1198 can_write = av_fifo_can_write(stream->fifo);
1200 ret = av_fifo_grow2(stream->fifo, size - can_write);
1207 if (!stream->predecode_packet) {
1208 stream->predecode_packet = pkt_desc;
1210 stream->last_packet->next = pkt_desc;
1211 stream->last_packet = pkt_desc;
1212 if (!stream->premux_packet)
1213 stream->premux_packet = pkt_desc;
1223 (pts - stream->vobu_start_pts >= 36000))) {
1224 stream->bytes_to_iframe = av_fifo_can_read(stream->fifo);
1225 stream->align_iframe = 1;
1226 stream->vobu_start_pts = pts;
1230 av_fifo_write(stream->fifo, buf, size);
1241 StreamInfo *stream;
1254 * complicates MPEG stream concatenation. */
1258 stream = ctx->streams[i]->priv_data;
1260 av_assert0(av_fifo_can_read(stream->fifo) == 0);
1268 StreamInfo *stream = ctx->streams[i]->priv_data;
1269 if (!stream)
1271 for (PacketDesc *pkt = stream->predecode_packet; pkt; ) {
1276 av_fifo_freep2(&stream->fifo);
1298 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 Systems / MPEG program stream"),
1315 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 Systems / MPEG program stream (VCD)"),