Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fftools/ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame);
if (err < 0)
goto fail;
av_frame_apply_cropping(decoded_frame, ist->dec_ctx->flags & AV_CODEC_FLAG_UNALIGNED ? AV_FRAME_CROP_UNALIGNED : 0);
}
ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;

Expand Down
7 changes: 5 additions & 2 deletions libavcodec/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,11 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
if (!avctx->apply_cropping)
return 0;

return av_frame_apply_cropping(frame, avctx->flags & AV_CODEC_FLAG_UNALIGNED ?
AV_FRAME_CROP_UNALIGNED : 0);
if (avctx->hwaccel) {
return 0;
} else {
return av_frame_apply_cropping(frame, avctx->flags & AV_CODEC_FLAG_UNALIGNED ? AV_FRAME_CROP_UNALIGNED : 0);
}
}

int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Expand Down
18 changes: 17 additions & 1 deletion libavcodec/vaapi_encode_mpeg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,15 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
"%d / %d / %d for I- / P- / B-frames.\n",
priv->quant_i, priv->quant_p, priv->quant_b);

} else if (ctx->va_rc_mode == VA_RC_CBR ||
ctx->va_rc_mode == VA_RC_VBR) {
priv->quant_i = 15;
priv->quant_p = 15;
priv->quant_b = 15;
av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n",
ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable",
avctx->bit_rate);

} else {
av_assert0(0 && "Invalid RC mode.");
}
Expand Down Expand Up @@ -625,7 +634,14 @@ static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)

ctx->va_entrypoint = VAEntrypointEncSlice;
ctx->va_rt_format = VA_RT_FORMAT_YUV420;
ctx->va_rc_mode = VA_RC_CQP;

if (avctx->bit_rate > 0) {
if (avctx->rc_max_rate == avctx->bit_rate)
ctx->va_rc_mode = VA_RC_CBR;
else
ctx->va_rc_mode = VA_RC_VBR;
} else
ctx->va_rc_mode = VA_RC_CQP;

ctx->va_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE |
VA_ENC_PACKED_HEADER_PICTURE;
Expand Down
12 changes: 0 additions & 12 deletions libavutil/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,18 +889,6 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
if (!desc)
return AVERROR_BUG;

/* Apply just the right/bottom cropping for hwaccel formats. Bitstream
* formats cannot be easily handled here either (and corresponding decoders
* should not export any cropping anyway), so do the same for those as well.
* */
if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL)) {
frame->width -= frame->crop_right;
frame->height -= frame->crop_bottom;
frame->crop_right = 0;
frame->crop_bottom = 0;
return 0;
}

/* calculate the offsets for each plane */
calc_cropping_offsets(offsets, frame, desc);

Expand Down
47 changes: 45 additions & 2 deletions tests/fate-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ gen=${16:-no}
hwaccel=${17:-none}
report_type=${18:-standard}
keep=${19:-0}
output_pixfmt=${20:-yuv420p}

outdir="tests/data/fate"
outfile="${outdir}/${test}"
Expand Down Expand Up @@ -132,15 +133,57 @@ ffmpeg(){
}

framecrc(){
ffmpeg "$@" -bitexact -f framecrc -
match_hwaccel="vaapi"
match_result=$(echo "$hwaccel" | grep ${match_hwaccel})
if [ "$match_result" != "" ]
then
match_str="format"
result=$(echo "$@" | grep ${match_str})
if [ "$result" != "" ]
then
ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framecrc -
else
match_str="pix_fmt"
result=$(echo "$@" | grep ${match_str})
if [ "$result" != "" ]
then
ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framecrc -
else
ffmpeg "$@" -pix_fmt $output_pixfmt -flags +bitexact -fflags +bitexact -f framecrc -
fi
fi
else
ffmpeg "$@" -bitexact -f framecrc -
fi
}

ffmetadata(){
ffmpeg "$@" -bitexact -f ffmetadata -
}

framemd5(){
ffmpeg "$@" -bitexact -f framemd5 -
match_hwaccel="vaapi"
match_result=$(echo "$hwaccel" | grep ${match_hwaccel})
if [ "$match_result" != "" ]
then
match_str="format"
result=$(echo "$@" | grep ${match_str})
if [ "$result" != "" ]
then
ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framemd5 -
else
match_str="pix_fmt"
result=$(echo "$@" | grep ${match_str})
if [ "$result" != "" ]
then
ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framemd5 -
else
ffmpeg "$@" -pix_fmt $output_pixfmt -flags +bitexact -fflags +bitexact -f framemd5 -
fi
fi
else
ffmpeg "$@" -bitexact -f framemd5 -
fi
}

crc(){
Expand Down