examples: remove some trailing spaces
am7xxx-play: add a comment to explain why a run-time warning can be ignored Using the AV_PIX_FMT_YUVJ420P pixel format results n a run-time warning from swscaler: [swscaler @ 0x5600046b3cc0] deprecated pixel format used, make sure you did set range correctly However this cannot be changed because the mjpeg codec relies on it, otherwise it fails with the following error message: [mjpeg @ 0x560eea5f5360] Specified pixel format yuv420p is invalid or not supported So just add a comment, to avoid loosing time figuring things out again in the future.
am7xxx-play: stop using avcodec_decode_video2() and avcodec_encode_video2() Since FFMpeg 3.1, avcodec_decode_video2() and avcodec_encode_video2() have been deprecated in favor of the more generic send/receive API. Provide some wrappers to ease the transition between the two APIs. The change fixes the following warnings: .../libam7xxx/examples/am7xxx-play.c: In function ‘am7xxx_play’: .../libam7xxx/examples/am7xxx-play.c:372:3: warning: ‘avcodec_decode_video2’ is deprecated [-Wdeprecated-declarations] ret = avcodec_decode_video2(input_ctx.codec_ctx, frame_raw, &got_frame, &in_packet); ^~~ In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:319:0, from /usr/include/x86_64-linux-gnu/libavdevice/avdevice.h:51, from .../libam7xxx/examples/am7xxx-play.c:32: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4993:5: note: declared here int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, ^~~~~~~~~~~~~~~~~~~~~ .../libam7xxx/examples/am7xxx-play.c:403:5: warning: ‘avcodec_encode_video2’ is deprecated [-Wdeprecated-declarations] ret = avcodec_encode_video2(output_ctx.codec_ctx, ^~~ In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:319:0, from /usr/include/x86_64-linux-gnu/libavdevice/avdevice.h:51, from .../libam7xxx/examples/am7xxx-play.c:32: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5508:5: note: declared here int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, ^~~~~~~~~~~~~~~~~~~~~
am7xxx-play: s/picture/frame/ to make the variable names match the data types No functional changes, just a word substitution to match more closely what the data types represent.
am7xxx-play: use av_find_best_stream() instead of open-coding the search
am7xxx-play: remove useless call to avcodec_close() in video_output_init() If the code reaches the "cleanup" exit path in video_output_init() the output codec context was never opened, so there is no need to close it.
am7xxx-play: free AVCodecContext variables with avcodec_free_context() Deallocate AVCodecContext variables with avcodec_free_context() instead of av_free() this is for symmetry with the allocation functions. Adjust and update the comment to the new code.
am7xxx-play: use AVStream.codecpar instead of the deprecated AVStream.codec AVStream.codec has been deprecated and AVStream.codecpar should be used instead, as shown in: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commitdiff;h=9200514ad8717c63f82101dc394f4378854325bf The changes fix the following compilation warnings: .../libam7xxx/examples/am7xxx-play.c: In function ‘video_input_init’: .../libam7xxx/examples/am7xxx-play.c:104:3: warning: ‘codec’ is deprecated [-Wdeprecated-declarations] if (input_format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { ^~ In file included from /usr/include/x86_64-linux-gnu/libavdevice/avdevice.h:51:0, from .../libam7xxx/examples/am7xxx-play.c:32: /usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here AVCodecContext *codec; ^~~~~ .../libam7xxx/examples/am7xxx-play.c:115:2: warning: ‘codec’ is deprecated [-Wdeprecated-declarations] input_codec_ctx = input_format_ctx->streams[video_index]->codec; ^~~~~~~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/libavdevice/avdevice.h:51:0, from .../libam7xxx/examples/am7xxx-play.c:32: /usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here AVCodecContext *codec; ^~~~~
am7xxx-play: don't override return value when there is a usable one Don't override the avcodec_open2() return value, we can pass along the negative return value as is to the caller.
am7xxx-play: remove some code which will never be executed input_codec_ctx is guaranteed to be defined here, otherwise the code would have bailed out earlier.
am7xxx-play: remove any usage of ENOTSUP There's really no need to use ENOTSUP here, the return value is not checked against the specific value, but just for the sign. Replacing it with EINVAL makes the code more aligned with the other error paths and also allows to remove a conditional define.
am7xxx-play: rename CODEC_FLAG_QSCALE to AV_CODEC_FLAG_QSCALE In FFMpeg 3.5+ the unprefixed CODEC_* constants have been removed, only the correspondent AV_CODEC_* ones are available. This fixes a build failure: .../examples/am7xxx-play.c: In function 'video_output_init': .../examples/am7xxx-play.c:240:34: error: 'CODEC_FLAG_QSCALE' undeclared (first use in this function); did you mean 'AV_CODEC_FLAG_QSCALE'? output_codec_ctx->flags |= CODEC_FLAG_QSCALE; ^~~~~~~~~~~~~~~~~ AV_CODEC_FLAG_QSCALE
am7xxx-play: get rid of the deprecated function av_free_packet() This also fixes this warning: warning: ‘av_free_packet’ is deprecated
am7xxx-play: get rd of the deprecated function avpicture_fill() This also fixes this warning: warning: ‘avpicture_fill’ is deprecated
am7xxx-play: get rid of the deprecated function avpicture_get_size() This also fixes this warning: warning: ‘avpicture_get_size’ is deprecated
am7xxx-play: add more informations about how the raw format is handled This new comment should make it easier to understand why there is no need to encode the frame when outputting data in the raw format supported by the device
am7xxx-play: output more informative message when get_x_screen_size() is a stub
am7xxx-play: fix warning about deprecated fields in the output codec .../examples/am7xxx-play.c:238:2: warning: ‘lmin’ is deprecated [-Wdeprecated-declarations] output_codec_ctx->mb_lmin = output_codec_ctx->lmin = output_codec_ctx->qmin * FF_QP2LAMBDA; ^ .../examples/am7xxx-play.c:239:2: warning: ‘lmax’ is deprecated [-Wdeprecated-declarations] output_codec_ctx->mb_lmax = output_codec_ctx->lmax = output_codec_ctx->qmax * FF_QP2LAMBDA; ^
am7xxx-play: don't dump the last frame unconditionally Stop dumping the last frame unconditionally in DEBUG mode, it's not the expected behavior; instead add an option to explicitly enable dumping the last frame but still leave this active only in DEBUG mode.
am7xxx-play: fix runtime warnings from ffmpeg ffmpeg emits warnings at runtime about some AVFrame fields not being set: [mjpeg @ 0x669040] AVFrame.format is not set [mjpeg @ 0x669040] AVFrame.width or height is not set This happens in a loop so the message is repeated over and over and becomes annoying, fix this by setting the missing values.