Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example
> -Original Message- > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf > Of Steven Liu > Sent: Monday, August 7, 2017 11:49 AM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder > example > > 2017-08-07 10:45 GMT+08:00 Li, Zhong <zhong...@intel.com>: > >> -Original Message- > >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On > Behalf > >> Of Steven Liu > >> Sent: Wednesday, August 2, 2017 2:01 PM > >> To: FFmpeg development discussions and patches > >> <ffmpeg-devel@ffmpeg.org> > >> Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv > >> encoder example > >> > >> 2017-08-03 1:27 GMT+08:00 Zhong Li <zhong...@intel.com>: > >> > It is an evolution from the exmaple "encode_video.c" to support qsv > >> encoder. > >> > > >> > V1->V2: Split to a separated qsv encoding example, instead of a > >> > V1->patch > >> > based on encode_video.c > >> > > >> > Signed-off-by: Zhong Li <zhong...@intel.com> > >> > --- > >> > configure | 2 + > >> > doc/Makefile | 1 + > >> > doc/examples/qsvenc.c | 211 > >> > ++ > >> > 3 files changed, 214 insertions(+) create mode 100644 > >> > doc/examples/qsvenc.c > >> > > >> > diff --git a/configure b/configure > >> > index 66c7b94..676cd85 100755 > >> > --- a/configure > >> > +++ b/configure > >> > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST=" > >> > metadata_example > >> > muxing_example > >> > qsvdec_example > >> > +qsvenc_example > >> > remuxing_example > >> > resampling_audio_example > >> > scaling_video_example > >> > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec > avformat > >> avutil" > >> > metadata_example_deps="avformat avutil" > >> > muxing_example_deps="avcodec avformat avutil swscale" > >> > qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder" > >> > +qsvenc_example_deps="avcodec avutil libmfx" > >> > remuxing_example_deps="avcodec avformat avutil" > >> > resampling_audio_example_deps="avutil swresample" > >> > scaling_video_example_deps="avutil swscale" > >> > diff --git a/doc/Makefile b/doc/Makefile index b670f0b..ed41763 > >> > 100644 > >> > --- a/doc/Makefile > >> > +++ b/doc/Makefile > >> > @@ -52,6 +52,7 @@ > DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) > >> += hw_decode > >> > DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += > >> metadata > >> > DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= > >> muxing > >> > DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= > qsvdec > >> > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= > qsvenc > >> > DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += > >> remuxing > >> > DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += > >> resampling_audio > >> > DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += > >> scaling_video > >> > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c new file > >> > mode 100644 index 000..3b94cc8 > >> > --- /dev/null > >> > +++ b/doc/examples/qsvenc.c > >> > @@ -0,0 +1,211 @@ > >> > +/* > >> > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li > >> > + * > >> > + * Permission is hereby granted, free of charge, to any person > >> > +obtaining a copy > >> > + * of this software and associated documentation files (the > >> > +"Software"), to deal > >> > + * in the Software without restriction, including without > >> > +limitation the rights > >> > + * to use, copy, modify, merge, publish, distribute, sublicense, > >> > +and/or sell > >> > + * copies of the Software, and to permit persons to whom the > >> > +Software is > >> > + * furnished to do so, subject to the following conditions: > >> > + * > >> > + * The above copyright notice and this permission
Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example
2017-08-07 10:45 GMT+08:00 Li, Zhong <zhong...@intel.com>: >> -Original Message- >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf >> Of Steven Liu >> Sent: Wednesday, August 2, 2017 2:01 PM >> To: FFmpeg development discussions and patches >> <ffmpeg-devel@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder >> example >> >> 2017-08-03 1:27 GMT+08:00 Zhong Li <zhong...@intel.com>: >> > It is an evolution from the exmaple "encode_video.c" to support qsv >> encoder. >> > >> > V1->V2: Split to a separated qsv encoding example, instead of a patch >> > based on encode_video.c >> > >> > Signed-off-by: Zhong Li <zhong...@intel.com> >> > --- >> > configure | 2 + >> > doc/Makefile | 1 + >> > doc/examples/qsvenc.c | 211 >> > ++ >> > 3 files changed, 214 insertions(+) >> > create mode 100644 doc/examples/qsvenc.c >> > >> > diff --git a/configure b/configure >> > index 66c7b94..676cd85 100755 >> > --- a/configure >> > +++ b/configure >> > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST=" >> > metadata_example >> > muxing_example >> > qsvdec_example >> > +qsvenc_example >> > remuxing_example >> > resampling_audio_example >> > scaling_video_example >> > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec avformat >> avutil" >> > metadata_example_deps="avformat avutil" >> > muxing_example_deps="avcodec avformat avutil swscale" >> > qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder" >> > +qsvenc_example_deps="avcodec avutil libmfx" >> > remuxing_example_deps="avcodec avformat avutil" >> > resampling_audio_example_deps="avutil swresample" >> > scaling_video_example_deps="avutil swscale" >> > diff --git a/doc/Makefile b/doc/Makefile index b670f0b..ed41763 100644 >> > --- a/doc/Makefile >> > +++ b/doc/Makefile >> > @@ -52,6 +52,7 @@ DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) >> += hw_decode >> > DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += >> metadata >> > DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= >> muxing >> > DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec >> > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= qsvenc >> > DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += >> remuxing >> > DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += >> resampling_audio >> > DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += >> scaling_video >> > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c new file >> > mode 100644 index 000..3b94cc8 >> > --- /dev/null >> > +++ b/doc/examples/qsvenc.c >> > @@ -0,0 +1,211 @@ >> > +/* >> > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li >> > + * >> > + * Permission is hereby granted, free of charge, to any person >> > +obtaining a copy >> > + * of this software and associated documentation files (the >> > +"Software"), to deal >> > + * in the Software without restriction, including without limitation >> > +the rights >> > + * to use, copy, modify, merge, publish, distribute, sublicense, >> > +and/or sell >> > + * copies of the Software, and to permit persons to whom the Software >> > +is >> > + * furnished to do so, subject to the following conditions: >> > + * >> > + * The above copyright notice and this permission notice shall be >> > +included in >> > + * all copies or substantial portions of the Software. >> > + * >> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY >> KIND, >> > +EXPRESS OR >> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> > +MERCHANTABILITY, >> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO >> EVENT >> > +SHALL >> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, >> DAMAGES >> > +OR OTHER >> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR >> OTHERWISE, >> > +ARISING FROM, >> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> OTHER >> > +DEALINGS IN >>
Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example
> -Original Message- > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf > Of Steven Liu > Sent: Wednesday, August 2, 2017 2:01 PM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder > example > > 2017-08-03 1:27 GMT+08:00 Zhong Li <zhong...@intel.com>: > > It is an evolution from the exmaple "encode_video.c" to support qsv > encoder. > > > > V1->V2: Split to a separated qsv encoding example, instead of a patch > > based on encode_video.c > > > > Signed-off-by: Zhong Li <zhong...@intel.com> > > --- > > configure | 2 + > > doc/Makefile | 1 + > > doc/examples/qsvenc.c | 211 > > ++ > > 3 files changed, 214 insertions(+) > > create mode 100644 doc/examples/qsvenc.c > > > > diff --git a/configure b/configure > > index 66c7b94..676cd85 100755 > > --- a/configure > > +++ b/configure > > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST=" > > metadata_example > > muxing_example > > qsvdec_example > > +qsvenc_example > > remuxing_example > > resampling_audio_example > > scaling_video_example > > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec avformat > avutil" > > metadata_example_deps="avformat avutil" > > muxing_example_deps="avcodec avformat avutil swscale" > > qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder" > > +qsvenc_example_deps="avcodec avutil libmfx" > > remuxing_example_deps="avcodec avformat avutil" > > resampling_audio_example_deps="avutil swresample" > > scaling_video_example_deps="avutil swscale" > > diff --git a/doc/Makefile b/doc/Makefile index b670f0b..ed41763 100644 > > --- a/doc/Makefile > > +++ b/doc/Makefile > > @@ -52,6 +52,7 @@ DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) > += hw_decode > > DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += > metadata > > DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= > muxing > > DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec > > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= qsvenc > > DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += > remuxing > > DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += > resampling_audio > > DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += > scaling_video > > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c new file > > mode 100644 index 000..3b94cc8 > > --- /dev/null > > +++ b/doc/examples/qsvenc.c > > @@ -0,0 +1,211 @@ > > +/* > > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li > > + * > > + * Permission is hereby granted, free of charge, to any person > > +obtaining a copy > > + * of this software and associated documentation files (the > > +"Software"), to deal > > + * in the Software without restriction, including without limitation > > +the rights > > + * to use, copy, modify, merge, publish, distribute, sublicense, > > +and/or sell > > + * copies of the Software, and to permit persons to whom the Software > > +is > > + * furnished to do so, subject to the following conditions: > > + * > > + * The above copyright notice and this permission notice shall be > > +included in > > + * all copies or substantial portions of the Software. > > + * > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY > KIND, > > +EXPRESS OR > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > > +MERCHANTABILITY, > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO > EVENT > > +SHALL > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, > DAMAGES > > +OR OTHER > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR > OTHERWISE, > > +ARISING FROM, > > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > OTHER > > +DEALINGS IN > > + * THE SOFTWARE. > > + */ > > + > > +/** > > + * @file > > + * Intel QSV-accelerated encoding example > > + * > > + * @example qsvenc.c > > + */ > > + > > +#include > > +#include > > +#include > > + > > +#include > > + > > +#include > > +#include > > +#include "libavutil/buffer.h" > > +#include "libavutil/hwcontext.h" > > + > > +s
Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example
2017-08-03 1:27 GMT+08:00 Zhong Li: > It is an evolution from the exmaple "encode_video.c" to support qsv encoder. > > V1->V2: Split to a separated qsv encoding example, instead of a patch > based on encode_video.c > > Signed-off-by: Zhong Li > --- > configure | 2 + > doc/Makefile | 1 + > doc/examples/qsvenc.c | 211 > ++ > 3 files changed, 214 insertions(+) > create mode 100644 doc/examples/qsvenc.c > > diff --git a/configure b/configure > index 66c7b94..676cd85 100755 > --- a/configure > +++ b/configure > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST=" > metadata_example > muxing_example > qsvdec_example > +qsvenc_example > remuxing_example > resampling_audio_example > scaling_video_example > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec avformat avutil" > metadata_example_deps="avformat avutil" > muxing_example_deps="avcodec avformat avutil swscale" > qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder" > +qsvenc_example_deps="avcodec avutil libmfx" > remuxing_example_deps="avcodec avformat avutil" > resampling_audio_example_deps="avutil swresample" > scaling_video_example_deps="avutil swscale" > diff --git a/doc/Makefile b/doc/Makefile > index b670f0b..ed41763 100644 > --- a/doc/Makefile > +++ b/doc/Makefile > @@ -52,6 +52,7 @@ DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += > hw_decode > DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata > DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= muxing > DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= qsvenc > DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing > DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio > DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c > new file mode 100644 > index 000..3b94cc8 > --- /dev/null > +++ b/doc/examples/qsvenc.c > @@ -0,0 +1,211 @@ > +/* > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +/** > + * @file > + * Intel QSV-accelerated encoding example > + * > + * @example qsvenc.c > + */ > + > +#include > +#include > +#include > + > +#include > + > +#include > +#include > +#include "libavutil/buffer.h" > +#include "libavutil/hwcontext.h" > + > +static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, > + FILE *outfile) > +{ > +int ret; > + > +/* send the frame to the encoder */ > +if (frame) > +printf("Send frame %3"PRId64"\n", frame->pts); > + > +ret = avcodec_send_frame(enc_ctx, frame); > +if (ret < 0) { > +fprintf(stderr, "Error sending a frame for encoding\n"); > +exit(1); > +} > + > +while (ret >= 0) { > +ret = avcodec_receive_packet(enc_ctx, pkt); > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) > +return; > +else if (ret < 0) { > +fprintf(stderr, "Error during encoding\n"); > +exit(1); > +} > + > +printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size); > +fwrite(pkt->data, 1, pkt->size, outfile); > +av_packet_unref(pkt); > +} > +} > + > +int main(int argc, char **argv) > +{ > +const char *filename, *codec_name; > +const AVCodec *codec; > +AVCodecContext *c= NULL; Why don't use AVCodecParameters? > +int i, ret, x, y; > +FILE *f; > +AVFrame *frame; > +AVPacket *pkt; > +AVBufferRef *encode_device = NULL; > + > +if (argc <= 2) { > +fprintf(stderr, "Usage: %s \n", argv[0]); > +exit(0); > +} > +filename = argv[1]; > +codec_name = argv[2]; > + > +if