Skip to content

Commit

Permalink
to_lavc_vid_conv: set AVFrame CS and range
Browse files Browse the repository at this point in the history
Some encoders use `colorspace` and `color_range` from AVFrame,
eg. _hevc_videotoolbox_:

   uv -t testcard -c libavcodec:encoder=hevc_videotoolbox

(defaults to bgra, because other foramts don't keep 4:2:2 subsampling,
supported at the time: videotoolbox_vld nv12 yuv420p bgra p010le).

Fixed error was producing this message:
````
[lavc hevc_videotoolbox @ 0x12fc04190] Could not get pixel format for color format 'bgra' range 'unknown'.
[lavc hevc_videotoolbox @ 0x12fc04190] Error: Cannot convert format 28 color_range 0: -22
```
  • Loading branch information
MartinPulec committed Oct 31, 2023
1 parent c5e5547 commit 37ae393
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libavcodec/to_lavc_vid_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,11 @@ struct to_lavc_vid_conv *to_lavc_vid_conv_init(codec_t in_pixfmt, int width, int
s->tmp_frame->width = s->out_frame->width = width;
s->tmp_frame->height =s->out_frame->height = height;

get_av_pixfmt_details(out_pixfmt, &s->out_frame->colorspace,
&s->out_frame->color_range);
get_av_pixfmt_details(out_pixfmt, &s->tmp_frame->colorspace,
&s->tmp_frame->color_range);

ret = av_frame_get_buffer(s->out_frame, 0);
if (ret < 0) {
log_msg(LOG_LEVEL_ERROR, "Could not allocate raw picture buffer\n");
Expand Down

0 comments on commit 37ae393

Please sign in to comment.