Browse code

Merge commit '8633fb47db2ec39eb8bd1bd65302af75a94ff5d0'

* commit '8633fb47db2ec39eb8bd1bd65302af75a94ff5d0':
rtpdec_hevc: Share the implementation of parsing a=framesize with h264

Conflicts:
libavformat/rtpdec_h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2015/02/25 07:03:12
Showing 3 changed files
... ...
@@ -42,6 +42,7 @@ int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, PayloadContext *data,
42 42
                                      const uint8_t *buf, int len,
43 43
                                      int start_skip, int *nal_counters,
44 44
                                      int nal_mask);
45
+void ff_h264_parse_framesize(AVCodecContext *codec, const char *p);
45 46
 
46 47
 extern RTPDynamicProtocolHandler ff_ac3_dynamic_handler;
47 48
 extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler;
... ...
@@ -177,6 +177,28 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
177 177
     return 0;
178 178
 }
179 179
 
180
+void ff_h264_parse_framesize(AVCodecContext *codec, const char *p)
181
+{
182
+    char buf1[50];
183
+    char *dst = buf1;
184
+
185
+    // remove the protocol identifier
186
+    while (*p && *p == ' ')
187
+        p++;                     // strip spaces.
188
+    while (*p && *p != ' ')
189
+        p++;                     // eat protocol identifier
190
+    while (*p && *p == ' ')
191
+        p++;                     // strip trailing spaces.
192
+    while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1)
193
+        *dst++ = *p++;
194
+    *dst = '\0';
195
+
196
+    // a='framesize:96 320-240'
197
+    // set our parameters
198
+    codec->width   = atoi(buf1);
199
+    codec->height  = atoi(p + 1); // skip the -
200
+}
201
+
180 202
 int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, PayloadContext *data, AVPacket *pkt,
181 203
                                      const uint8_t *buf, int len,
182 204
                                      int skip_between, int *nal_counters,
... ...
@@ -361,34 +383,15 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
361 361
                                PayloadContext *h264_data, const char *line)
362 362
 {
363 363
     AVStream *stream;
364
-    AVCodecContext *codec;
365 364
     const char *p = line;
366 365
 
367 366
     if (st_index < 0)
368 367
         return 0;
369 368
 
370 369
     stream = s->streams[st_index];
371
-    codec  = stream->codec;
372 370
 
373 371
     if (av_strstart(p, "framesize:", &p)) {
374
-        char buf1[50];
375
-        char *dst = buf1;
376
-
377
-        // remove the protocol identifier
378
-        while (*p && *p == ' ')
379
-            p++;                     // strip spaces.
380
-        while (*p && *p != ' ')
381
-            p++;                     // eat protocol identifier
382
-        while (*p && *p == ' ')
383
-            p++;                     // strip trailing spaces.
384
-        while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1)
385
-            *dst++ = *p++;
386
-        *dst = '\0';
387
-
388
-        // a='framesize:96 320-240'
389
-        // set our parameters
390
-        codec->width   = atoi(buf1);
391
-        codec->height  = atoi(p + 1); // skip the -
372
+        ff_h264_parse_framesize(stream->codec, p);
392 373
     } else if (av_strstart(p, "fmtp:", &p)) {
393 374
         return ff_parse_fmtp(s, stream, h264_data, p, sdp_parse_fmtp_config_h264);
394 375
     } else if (av_strstart(p, "cliprect:", &p)) {
... ...
@@ -142,33 +142,7 @@ static av_cold int hevc_parse_sdp_line(AVFormatContext *ctx, int st_index,
142 142
     codec  = current_stream->codec;
143 143
 
144 144
     if (av_strstart(sdp_line_ptr, "framesize:", &sdp_line_ptr)) {
145
-        char str_video_width[50];
146
-        char *str_video_width_ptr = str_video_width;
147
-
148
-        /*
149
-         * parse "a=framesize:96 320-240"
150
-         */
151
-
152
-        /* ignore spaces */
153
-        while (*sdp_line_ptr && *sdp_line_ptr == ' ')
154
-            sdp_line_ptr++;
155
-        /* ignore RTP payload ID */
156
-        while (*sdp_line_ptr && *sdp_line_ptr != ' ')
157
-            sdp_line_ptr++;
158
-        /* ignore spaces */
159
-        while (*sdp_line_ptr && *sdp_line_ptr == ' ')
160
-            sdp_line_ptr++;
161
-        /* extract the actual video resolution description */
162
-        while (*sdp_line_ptr && *sdp_line_ptr != '-' &&
163
-               (str_video_width_ptr - str_video_width) < sizeof(str_video_width) - 1)
164
-            *str_video_width_ptr++ = *sdp_line_ptr++;
165
-        /* add trailing zero byte */
166
-        *str_video_width_ptr = '\0';
167
-
168
-        /* determine the width value */
169
-        codec->width   = atoi(str_video_width);
170
-        /* jump beyond the "-" and determine the height value */
171
-        codec->height  = atoi(sdp_line_ptr + 1);
145
+        ff_h264_parse_framesize(codec, sdp_line_ptr);
172 146
     } else if (av_strstart(sdp_line_ptr, "fmtp:", &sdp_line_ptr)) {
173 147
         int ret = ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
174 148
                                 hevc_sdp_parse_fmtp_config);