-
Notifications
You must be signed in to change notification settings - Fork 4
Provide output pixel format #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mickel8
merged 4 commits into
elixir-webrtc:master
from
gBillal:provide-output-pixel-format
Jan 3, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,43 @@ | ||
| #include "video_converter.h" | ||
|
|
||
| int video_converter_convert(AVFrame *src_frame, uint8_t *out_data[], int out_linesize[]) { | ||
| int video_converter_convert(AVFrame *src_frame, AVFrame **dst_frame, enum AVPixelFormat out_format) { | ||
| int ret; | ||
|
|
||
| *dst_frame = av_frame_alloc(); | ||
| if (!*dst_frame) { | ||
| return -1; | ||
| } | ||
|
|
||
| (*dst_frame)->width = src_frame->width; | ||
| (*dst_frame)->height = src_frame->height; | ||
| (*dst_frame)->format = out_format; | ||
| (*dst_frame)->pts = src_frame->pts; | ||
|
|
||
| ret = av_frame_get_buffer(*dst_frame, 0); | ||
| if (ret < 0) { | ||
| return ret; | ||
| } | ||
|
|
||
| struct SwsContext *sws_ctx = | ||
| sws_getContext(src_frame->width, src_frame->height, src_frame->format, src_frame->width, | ||
| src_frame->height, AV_PIX_FMT_RGB24, SWS_BILINEAR, NULL, NULL, NULL); | ||
|
|
||
| ret = av_image_alloc(out_data, out_linesize, src_frame->width, src_frame->height, | ||
| AV_PIX_FMT_RGB24, 1); | ||
| src_frame->height, out_format, SWS_BILINEAR, NULL, NULL, NULL); | ||
|
|
||
| if (ret < 0) { | ||
| return ret; | ||
| } | ||
|
|
||
|
|
||
| // is this (const uint8_t * const*) cast really correct? | ||
| ret = sws_scale(sws_ctx, (const uint8_t *const *)src_frame->data, src_frame->linesize, 0, | ||
| src_frame->height, out_data, out_linesize); | ||
| src_frame->height, (*dst_frame)->data, (*dst_frame)->linesize); | ||
|
|
||
| if (ret < 0) { | ||
| av_freep(&out_data[0]); | ||
| av_frame_free(dst_frame); | ||
| sws_freeContext(sws_ctx); | ||
| return ret; | ||
| } | ||
|
|
||
| sws_freeContext(sws_ctx); | ||
|
|
||
| return ret; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,15 @@ defmodule Xav.Frame do | |
| @typedoc """ | ||
| Possible video frame formats. | ||
|
|
||
| Currently, only RGB is supported. | ||
| The list of accepted formats are all `ffmpeg` pixel formats. For a complete list run: | ||
|
|
||
| ```sh | ||
| ffmpeg -pix_fmts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Appreciate instruction how to get a list of possible formats! |
||
| ``` | ||
|
|
||
| An example of a pixel format is `:rgb24`. | ||
| """ | ||
| @type video_format() :: :rgb | ||
| @type video_format() :: atom() | ||
|
|
||
| @type format() :: audio_format() | video_format() | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thnk we should distinct between a case where someone didn't pass
out_formatand someone passedout_formatbut it was incorrect.In
decoder_init, we should check whetherout_formatis nil. If yes, setout_formatfield in decoder to null. If not, try to callav_get_pix_fmt. Ifav_get_pix_fmtreturnsAV_PIX_FMT_NONE, return an error.