On Fri, 9 Oct 2015 16:26:17 +0200
Luca Barbato <[email protected]> wrote:
> ---
> libavformat/yuv4mpegenc.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
> index 2caa364..ef1e775 100644
> --- a/libavformat/yuv4mpegenc.c
> +++ b/libavformat/yuv4mpegenc.c
> @@ -88,7 +88,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket
> *pkt)
> {
> AVStream *st = s->streams[pkt->stream_index];
> AVIOContext *pb = s->pb;
> - AVPicture *picture;
> + AVFrame *frame;
> int* first_pkt = s->priv_data;
> int width, height, h_chroma_shift, v_chroma_shift;
> int i;
> @@ -96,7 +96,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket
> *pkt)
> char buf1[20];
> uint8_t *ptr, *ptr1, *ptr2;
>
> - picture = (AVPicture *)pkt->data;
> + frame = (AVFrame *)pkt->data;
>
> /* for the first packet we have to output the header as well */
> if (*first_pkt) {
> @@ -118,10 +118,10 @@ static int yuv4_write_packet(AVFormatContext *s,
> AVPacket *pkt)
> width = st->codec->width;
> height = st->codec->height;
This confuses me. Why not take the size from the AVFrame? Note that
AVPicture has no width/height fields, so this is a new situation.
Same for the pixel format, probably.
> - ptr = picture->data[0];
> + ptr = frame->data[0];
> for (i = 0; i < height; i++) {
> avio_write(pb, ptr, width);
> - ptr += picture->linesize[0];
> + ptr += frame->linesize[0];
> }
>
> if (st->codec->pix_fmt != AV_PIX_FMT_GRAY8) {
> @@ -132,15 +132,15 @@ static int yuv4_write_packet(AVFormatContext *s,
> AVPacket *pkt)
> width = -(-width >> h_chroma_shift);
> height = -(-height >> v_chroma_shift);
>
> - ptr1 = picture->data[1];
> - ptr2 = picture->data[2];
> + ptr1 = frame->data[1];
> + ptr2 = frame->data[2];
> for (i = 0; i < height; i++) { /* Cb */
> avio_write(pb, ptr1, width);
> - ptr1 += picture->linesize[1];
> + ptr1 += frame->linesize[1];
> }
> for (i = 0; i < height; i++) { /* Cr */
> avio_write(pb, ptr2, width);
> - ptr2 += picture->linesize[2];
> + ptr2 += frame->linesize[2];
> }
> }
> return 0;
> @@ -153,8 +153,8 @@ static int yuv4_write_header(AVFormatContext *s)
> if (s->nb_streams != 1)
> return AVERROR(EIO);
>
> - if (s->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
> - av_log(s, AV_LOG_ERROR, "ERROR: Only rawvideo supported.\n");
> + if (s->streams[0]->codec->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
> + av_log(s, AV_LOG_ERROR, "ERROR: Codec not supported.\n");
> return AVERROR_INVALIDDATA;
> }
>
> @@ -182,8 +182,7 @@ AVOutputFormat ff_yuv4mpegpipe_muxer = {
> .extensions = "y4m",
> .priv_data_size = sizeof(int),
> .audio_codec = AV_CODEC_ID_NONE,
> - .video_codec = AV_CODEC_ID_RAWVIDEO,
> + .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME,
> .write_header = yuv4_write_header,
> .write_packet = yuv4_write_packet,
> - .flags = AVFMT_RAWPICTURE,
> };
I wonder if you really can change the format, without breaking anything
that uses libavformat to mux y4m.
Other than that, looks good.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel