diff mbox series

[FFmpeg-devel,2/8] avformat/rtpdec_rfc4175: use av_get_bits_per_pixel()

Message ID 1633515251-5156-2-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit f7823c9a3a2e51c94b166d5701f65642d5531889
Headers show
Series [FFmpeg-devel,1/8] avcodec/bitpacked: check av_buffer_ref result
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Limin Wang Oct. 6, 2021, 10:14 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/rtpdec_rfc4175.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
index 4daff4d..e1e1452 100644
--- a/libavformat/rtpdec_rfc4175.c
+++ b/libavformat/rtpdec_rfc4175.c
@@ -43,8 +43,8 @@  struct PayloadContext {
 static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
 {
     enum AVPixelFormat pixfmt = AV_PIX_FMT_NONE;
-    int bits_per_sample = 0;
     int tag = 0;
+    const AVPixFmtDescriptor *desc;
 
     if (!strncmp(data->sampling, "YCbCr-4:2:2", 11)) {
         tag = MKTAG('U', 'Y', 'V', 'Y');
@@ -52,11 +52,9 @@  static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
 
         if (data->depth == 8) {
             data->pgroup = 4;
-            bits_per_sample = 16;
             pixfmt = AV_PIX_FMT_UYVY422;
         } else if (data->depth == 10) {
             data->pgroup = 5;
-            bits_per_sample = 20;
             pixfmt = AV_PIX_FMT_YUV422P10;
         } else {
             return AVERROR_INVALIDDATA;
@@ -65,9 +63,10 @@  static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
         return AVERROR_INVALIDDATA;
     }
 
+    desc = av_pix_fmt_desc_get(pixfmt);
     stream->codecpar->format = pixfmt;
     stream->codecpar->codec_tag = tag;
-    stream->codecpar->bits_per_coded_sample = bits_per_sample;
+    stream->codecpar->bits_per_coded_sample = av_get_bits_per_pixel(desc);
     data->frame_size = data->width * data->height * data->pgroup / data->xinc;
 
     return 0;